public static dataModel.QuoteRequestEntity ToDataModel(this coreModel.QuoteRequest quoteRequest, PrimaryKeyResolvingMap pkMap) { if (quoteRequest == null) { throw new ArgumentNullException("quoteRequest"); } var retVal = new dataModel.QuoteRequestEntity(); pkMap.AddPair(quoteRequest, retVal); retVal.InjectFrom(quoteRequest); if (quoteRequest.ShipmentMethod != null) { retVal.ShipmentMethodCode = quoteRequest.ShipmentMethod.ShipmentMethodCode; retVal.ShipmentMethodOption = quoteRequest.ShipmentMethod.OptionName; } retVal.Currency = quoteRequest.Currency.ToString(); if (quoteRequest.Addresses != null) { retVal.Addresses = new ObservableCollection <dataModel.AddressEntity>(quoteRequest.Addresses.Select(x => x.ToDataModel())); } if (quoteRequest.Attachments != null) { retVal.Attachments = new ObservableCollection <dataModel.AttachmentEntity>(quoteRequest.Attachments.Select(x => x.ToDataModel())); } if (quoteRequest.Items != null) { retVal.Items = new ObservableCollection <dataModel.QuoteItemEntity>(quoteRequest.Items.Select(x => x.ToDataModel(pkMap))); } return(retVal); }
/// <summary> /// Patch changes /// </summary> /// <param name="source"></param> /// <param name="target"></param> public static void Patch(this dataModel.QuoteRequestEntity source, dataModel.QuoteRequestEntity target) { if (target == null) { throw new ArgumentNullException("target"); } target.Tag = source.Tag; var patchInjection = new PatchInjection <dataModel.QuoteRequestEntity>(x => x.CancelledDate, x => x.CancelReason, x => x.ChannelId, x => x.Comment, x => x.InnerComment, x => x.IsLocked, x => x.IsCancelled, x => x.LanguageCode, x => x.OrganizationId, x => x.OrganizationName, x => x.ReminderDate, x => x.Status, x => x.StoreId, x => x.StoreName, x => x.ShipmentMethodCode, x => x.ShipmentMethodOption, x => x.EmployeeId, x => x.EmployeeName, x => x.Currency, x => x.ManualShippingTotal, x => x.ManualRelDiscountAmount, x => x.ManualSubTotal, x => x.IsSubmitted, x => x.CustomerId, x => x.CustomerName); target.InjectFrom(patchInjection, source); if (!source.Addresses.IsNullCollection()) { source.Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => { return; }); } if (!source.Attachments.IsNullCollection()) { source.Attachments.Patch(target.Attachments, (sourceAttachment, targetAttachment) => { return; }); } if (!source.Items.IsNullCollection()) { source.Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem)); } }
public static dataModel.QuoteRequestEntity ToDataModel(this coreModel.QuoteRequest quoteRequest, PrimaryKeyResolvingMap pkMap) { if (quoteRequest == null) throw new ArgumentNullException("quoteRequest"); var retVal = new dataModel.QuoteRequestEntity(); pkMap.AddPair(quoteRequest, retVal); retVal.InjectFrom(quoteRequest); if (quoteRequest.ShipmentMethod != null) { retVal.ShipmentMethodCode = quoteRequest.ShipmentMethod.ShipmentMethodCode; retVal.ShipmentMethodOption = quoteRequest.ShipmentMethod.OptionName; } retVal.Currency = quoteRequest.Currency.ToString(); if (quoteRequest.Addresses != null) { retVal.Addresses = new ObservableCollection<dataModel.AddressEntity>(quoteRequest.Addresses.Select(x => x.ToDataModel())); } if (quoteRequest.Attachments != null) { retVal.Attachments = new ObservableCollection<dataModel.AttachmentEntity>(quoteRequest.Attachments.Select(x => x.ToDataModel())); } if (quoteRequest.Items != null) { retVal.Items = new ObservableCollection<dataModel.QuoteItemEntity>(quoteRequest.Items.Select(x => x.ToDataModel(pkMap))); } return retVal; }