refabrique du model d'erreurs
This commit is contained in:
parent
f95bc0311c
commit
2a625273fd
8 changed files with 77 additions and 46 deletions
|
|
@ -4,17 +4,28 @@ using ZicMoove.ViewModels.EstimateAndBilling;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xamarin.Forms;
|
||||
using ZicMoove.Model.Workflow;
|
||||
|
||||
namespace ZicMoove.Pages
|
||||
{
|
||||
public partial class EditBillingLinePage : ContentPage
|
||||
{
|
||||
public EditBillingLinePage(BillingLineViewModel model)
|
||||
public void Initialize()
|
||||
{
|
||||
InitializeComponent();
|
||||
foreach
|
||||
(string du in Enum.GetNames(typeof(BillingLineViewModel.DurationUnits)))
|
||||
foreach (string du in Enum.GetNames(typeof(BillingLineViewModel.DurationUnits)))
|
||||
picker.Items.Add(du);
|
||||
BindingContext = new BillingLineViewModel(new BillingLine());
|
||||
}
|
||||
|
||||
public EditBillingLinePage()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public EditBillingLinePage(BillingLineViewModel model)
|
||||
{
|
||||
Initialize();
|
||||
BindingContext = model;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,25 +22,16 @@ namespace ZicMoove.Pages
|
|||
public EditEstimatePage(EditEstimateViewModel model)
|
||||
{
|
||||
BindingContext = model;
|
||||
Model.CheckCommand = new Action<Estimate, ViewModels.Validation.ModelState>(
|
||||
(e, m) =>
|
||||
{
|
||||
foreach (var line in model.Bill)
|
||||
{
|
||||
line.Check();
|
||||
if (!line.ViewModelState.IsValid)
|
||||
model.ViewModelState.AddError("Bill", "invalid line");
|
||||
}
|
||||
});
|
||||
|
||||
InitializeComponent();
|
||||
Model.Check();
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
base.OnBindingContextChanged();
|
||||
((EditEstimateViewModel)BindingContext).PropertyChanged += EditEstimatePage_PropertyChanged;
|
||||
if (Model == null) return;
|
||||
Model.PropertyChanged += EditEstimatePage_PropertyChanged;
|
||||
Model.Check();
|
||||
}
|
||||
|
||||
private void EditEstimatePage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue