From d562bf398822aecf8299a36c32454bfe7d03e300 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Mon, 3 Oct 2016 18:34:14 +0200 Subject: [PATCH] an Validate command --- .../ViewModels/BillingLineViewModel.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) 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; + } }