public static dataModel.Pricelist ToDataModel(this coreModel.Pricelist priceList) { if (priceList == null) throw new ArgumentNullException("priceList"); var retVal = new dataModel.Pricelist(); retVal.InjectFrom(priceList); retVal.Currency = priceList.Currency.ToString(); retVal.Prices = new NullCollection<dataModel.Price>(); if (priceList.Prices != null) { retVal.Prices = new ObservableCollection<dataModel.Price>(priceList.Prices.Select(x=>x.ToDataModel())); } return retVal; }
/// <summary> /// Patch changes /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.Pricelist source, dataModel.Pricelist target) { if (target == null) { throw new ArgumentNullException("target"); } var patchInjection = new PatchInjection <dataModel.Pricelist>(x => x.Name, x => x.Currency, x => x.Description); target.InjectFrom(patchInjection, source); if (!source.Prices.IsNullCollection()) { source.Prices.Patch(target.Prices, (sourcePrice, targetPrice) => sourcePrice.Patch(targetPrice)); } if (!source.Assignments.IsNullCollection()) { source.Assignments.Patch(target.Assignments, (sourceAssignment, targetAssignment) => sourceAssignment.Patch(targetAssignment)); } }
public static dataModel.Pricelist ToDataModel(this coreModel.Pricelist priceList) { if (priceList == null) { throw new ArgumentNullException("priceList"); } var retVal = new dataModel.Pricelist(); retVal.InjectFrom(priceList); retVal.Currency = priceList.Currency.ToString(); retVal.Prices = new NullCollection <dataModel.Price>(); if (priceList.Prices != null) { retVal.Prices = new ObservableCollection <dataModel.Price>(priceList.Prices.Select(x => x.ToDataModel())); } if (priceList.Assignments != null) { retVal.Assignments = new ObservableCollection <dataModel.PricelistAssignment>(priceList.Assignments.Select(x => x.ToDataModel())); } return(retVal); }