diff --git a/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs b/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs index da39a0a0..fb2feb5c 100644 --- a/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs +++ b/BookAStar/BookAStar/ViewModels/BillingLineViewModel.cs @@ -1,19 +1,27 @@ using BookAStar.Interfaces; using BookAStar.Model.Workflow; using System; +using System.Windows.Input; +using Xamarin.Forms; using XLabs.Forms.Mvvm; namespace BookAStar.ViewModels { 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(); - count = data.Count; - description = data.Description; - unitaryCost = data.UnitaryCost; - duration = data.Duration; + this.data = (data == null) ? new BillingLine() : data; + Billing = billing; + ValidateCommand = + new Command( + () => { + Billing.Bill.Add(data); + Validated.Invoke(this, new EventArgs()); + }); } protected int count; @@ -69,5 +77,10 @@ namespace BookAStar.ViewModels SetProperty(ref unitaryCost, value, "UnitaryCost"); } } + + public ICommand ValidateCommand { protected set; get; } + + public event EventHandler Validated; + } }