1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
public void UpdateSpecialDates(ShippingView shippingView, NotifyCollectionChangedEventArgs e)
{
var shipping = shippingView.Shipping;
if(e.Action == NotifyCollectionChangedAction.Add)
foreach (SpecialDeliveryDateView view in e.NewItems)
{
if(shipping.FindSpecialDate(view.Date) == null)
shipping.AddSpecialDate(view.Date, view.NbDaysPreparations, view.Infos, view.IsDeliveryPossible);
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
foreach (SpecialDeliveryDateView view in e.OldItems)
{
var specialDateModel = shipping.FindSpecialDate(view.Date);
if (specialDateModel != null)
shipping.RemoveSpecialDate(specialDateModel);
}
}
public void UpdateSpecialDate(ShippingView shippingView, SpecialDeliveryDateView specialDateView, string propertyName)
{
var shipping = shippingView.Shipping;
SpecialDeliveryDate specialDateModel = shipping.FindSpecialDate(specialDateView.Date);
switch (propertyName)
{
case ("Infos"):
specialDateModel.Infos = specialDateView.Infos;
break;
case ("IsDeliveryPossible"):
specialDateModel.IsDeliveryPossible = specialDateView.IsDeliveryPossible;
break;
case ("NbDaysPreparations"):
specialDateModel.NbDaysPreparations = specialDateView.NbDaysPreparations;
break;
}
} |