refabrique du model d'erreurs
This commit is contained in:
parent
f95bc0311c
commit
2a625273fd
8 changed files with 77 additions and 46 deletions
|
|
@ -16,15 +16,6 @@ namespace ZicMoove.ViewModels.EstimateAndBilling
|
|||
|
||||
public BillingLineViewModel(BillingLine data): base(data)
|
||||
{
|
||||
CheckCommand = new Action<BillingLine, ModelState>(
|
||||
(l,s) => {
|
||||
if (string.IsNullOrWhiteSpace(l.Description))
|
||||
{
|
||||
s.AddError("Description",Strings.NoDescription);
|
||||
}
|
||||
if (l.UnitaryCost < 0) { s.AddError("UnitaryCost", Strings.InvalidValue); }
|
||||
if (l.Count < 0) { s.AddError("Count", Strings.InvalidValue); }
|
||||
});
|
||||
SyncData();
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +30,7 @@ namespace ZicMoove.ViewModels.EstimateAndBilling
|
|||
description = Data.Description;
|
||||
unitaryCostText = Data.UnitaryCost.ToString("G", CultureInfo.InvariantCulture);
|
||||
}
|
||||
CheckCommand(Data, ViewModelState);
|
||||
Check();
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
|
|
@ -51,6 +42,17 @@ namespace ZicMoove.ViewModels.EstimateAndBilling
|
|||
}
|
||||
}
|
||||
|
||||
public override void Check()
|
||||
{
|
||||
ModelState.Clear();
|
||||
if (string.IsNullOrWhiteSpace(Data.Description))
|
||||
{
|
||||
ModelState.AddError("Description", Strings.NoDescription);
|
||||
}
|
||||
if (Data.UnitaryCost < 0) { ModelState.AddError("UnitaryCost", Strings.InvalidValue); }
|
||||
if (Data.Count < 0) { ModelState.AddError("Count", Strings.InvalidValue); }
|
||||
}
|
||||
|
||||
private int count;
|
||||
public int Count
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ namespace ZicMoove.ViewModels.EstimateAndBilling
|
|||
using Model.Social;
|
||||
using Validation;
|
||||
using Model.Musical;
|
||||
using System;
|
||||
|
||||
public class EditEstimateViewModel : EditingViewModel<Estimate>
|
||||
{
|
||||
|
|
@ -52,7 +53,7 @@ namespace ZicMoove.ViewModels.EstimateAndBilling
|
|||
NotifyPropertyChanged("Query");
|
||||
NotifyPropertyChanged("CLient");
|
||||
NotifyPropertyChanged("ModelState");
|
||||
|
||||
Check();
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
|
|
@ -76,6 +77,30 @@ namespace ZicMoove.ViewModels.EstimateAndBilling
|
|||
NotifyPropertyChanged("ViewModelState");
|
||||
}
|
||||
|
||||
public override void Check()
|
||||
{
|
||||
ModelState.Clear();
|
||||
if (Data == null) return;
|
||||
if (string.IsNullOrWhiteSpace(Data.Title))
|
||||
ModelState.AddError("Title", "Spécifier un titre");
|
||||
if (string.IsNullOrWhiteSpace(Data.Description))
|
||||
ModelState.AddError("Description", "Veuillez décrire l'objet de cette facture");
|
||||
if (Data.Bill==null)
|
||||
ModelState.AddError("Bill", "Veuillez ajouter au moins une ligne de facture");
|
||||
else
|
||||
{
|
||||
if (Data.Bill.Count==0)
|
||||
ModelState.AddError("Bill", "Veuillez ajouter au moins une ligne de facture");
|
||||
var ilc = (Bill.Count(l => !l.ModelState.IsValid));
|
||||
if (ilc > 0)
|
||||
{
|
||||
var pluriel = (ilc > 1) ? "les lignes" : "la ligne";
|
||||
ModelState.AddError("Bill", "Veuillez corriger {pluriel} de facture");
|
||||
}
|
||||
}
|
||||
NotifyPropertyChanged("ModelState");
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public ObservableCollection<string> AttachedFiles
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue