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 coreModel.QuoteRequest ToCoreModel(this dataModel.QuoteRequestEntity dbEntity)
        {
            if (dbEntity == null)
            {
                throw new ArgumentNullException("dbEntity");
            }

            var retVal = new coreModel.QuoteRequest();

            retVal.InjectFrom(dbEntity);
            if (dbEntity.ShipmentMethodCode != null)
            {
                retVal.ShipmentMethod = new Domain.Quote.Model.ShipmentMethod
                {
                    OptionName         = dbEntity.ShipmentMethodOption,
                    ShipmentMethodCode = dbEntity.ShipmentMethodCode
                };
            }
            retVal.Currency    = dbEntity.Currency;
            retVal.Addresses   = dbEntity.Addresses.Select(x => x.ToCoreModel()).ToList();
            retVal.Attachments = dbEntity.Attachments.Select(x => x.ToCoreModel()).ToList();
            retVal.Items       = dbEntity.Items.Select(x => x.ToCoreModel()).ToList();

            return(retVal);
        }
        public void Patch(QuoteRequestEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            var _ = this;

            target.Number             = _.Number;
            target.StoreId            = _.StoreId;
            target.ChannelId          = _.ChannelId;
            target.IsAnonymous        = _.IsAnonymous;
            target.CustomerId         = _.CustomerId;
            target.CustomerName       = _.CustomerName;
            target.OrganizationName   = _.OrganizationName;
            target.OrganizationId     = _.OrganizationId;
            target.EmployeeId         = _.EmployeeId;
            target.EmployeeName       = _.EmployeeName;
            target.ExpirationDate     = _.ExpirationDate;
            target.ReminderDate       = _.ReminderDate;
            target.EnableNotification = _.EnableNotification;
            target.IsLocked           = _.IsLocked;
            target.Status             = _.Status;
            target.Tag                     = _.Tag;
            target.Comment                 = _.Comment;
            target.InnerComment            = _.InnerComment;
            target.Currency                = _.Currency;
            target.Coupon                  = _.Coupon;
            target.ManualShippingTotal     = _.ManualShippingTotal;
            target.ManualSubTotal          = _.ManualSubTotal;
            target.ManualRelDiscountAmount = _.ManualRelDiscountAmount;
            target.LanguageCode            = _.LanguageCode;
            target.IsCancelled             = _.IsCancelled;
            target.CancelledDate           = _.CancelledDate;
            target.CancelReason            = _.CancelReason;

            target.StoreName            = _.StoreName;
            target.ShipmentMethodCode   = _.ShipmentMethodCode;
            target.ShipmentMethodOption = _.ShipmentMethodOption;
            target.IsSubmitted          = _.IsSubmitted;

            if (!Addresses.IsNullCollection())
            {
                Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => { sourceAddress.Patch(targetAddress); });
            }
            if (!Attachments.IsNullCollection())
            {
                Attachments.Patch(target.Attachments, (sourceAttachment, targetAttachment) => { sourceAttachment.Patch(targetAttachment); });
            }
            if (!Items.IsNullCollection())
            {
                Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
            }
            if (!DynamicPropertyObjectValues.IsNullCollection())
            {
                DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues));
            }
        }
        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;
		}