an Validate command

vnext
Paul Schneider 8 years ago
parent 7ff5411cb2
commit 6c81683601
1 changed files with 19 additions and 6 deletions

@ -1,19 +1,27 @@
using BookAStar.Interfaces; using BookAStar.Interfaces;
using BookAStar.Model.Workflow; using BookAStar.Model.Workflow;
using System; using System;
using System.Windows.Input;
using Xamarin.Forms;
using XLabs.Forms.Mvvm; using XLabs.Forms.Mvvm;
namespace BookAStar.ViewModels namespace BookAStar.ViewModels
{ {
public class BillingLineViewModel : ViewModel, IBillingLine public class BillingLineViewModel : ViewModel, IBillingLine
{ {
public BillingLineViewModel(BillingLine data) BillingLine data;
public Estimate Billing { protected set; get; }
public BillingLineViewModel(Estimate billing, BillingLine data)
{ {
if (data == null) data = new BillingLine(); this.data = (data == null) ? new BillingLine() : data;
count = data.Count; Billing = billing;
description = data.Description; ValidateCommand =
unitaryCost = data.UnitaryCost; new Command(
duration = data.Duration; () => {
Billing.Bill.Add(data);
Validated.Invoke(this, new EventArgs());
});
} }
protected int count; protected int count;
@ -69,5 +77,10 @@ namespace BookAStar.ViewModels
SetProperty<decimal>(ref unitaryCost, value, "UnitaryCost"); SetProperty<decimal>(ref unitaryCost, value, "UnitaryCost");
} }
} }
public ICommand ValidateCommand { protected set; get; }
public event EventHandler<EventArgs> Validated;
} }
} }

Loading…