public static ShipmentPackageEntity ToDataModel(this ShipmentPackage package, CustomerOrderEntity orderEntity) { if (package == null) throw new ArgumentNullException("package"); var retVal = new ShipmentPackageEntity(); retVal.InjectFrom(package); if(package.Items != null) { retVal.Items = new ObservableCollection<ShipmentItemEntity>(package.Items.Select(x => x.ToDataModel(orderEntity))); } return retVal; }
/// <summary> /// Patch CatalogBase type /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this ShipmentPackageEntity source, ShipmentPackageEntity target) { if (target == null) throw new ArgumentNullException("target"); var patchInjectionPolicy = new PatchInjection<ShipmentPackageEntity>(x => x.PackageType, x => x.Weight, x => x.ShipmentId, x => x.Height, x => x.Length, x => x.Width, x => x.MeasureUnit, x => x.WeightUnit); if (!source.Items.IsNullCollection()) { source.Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem)); } target.InjectFrom(patchInjectionPolicy, source); }
public virtual void Patch(ShipmentPackageEntity target) { if (target == null) { throw new ArgumentNullException("target"); } target.PackageType = this.PackageType; target.ShipmentId = this.ShipmentId; target.Weight = this.Weight; target.Height = this.Height; target.Width = this.Width; target.MeasureUnit = this.MeasureUnit; target.WeightUnit = this.WeightUnit; target.Length = this.Length; if (!this.Items.IsNullCollection()) { this.Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem)); } }