public virtual void Patch(LineItemEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.ListPrice        = ListPrice;
            target.ListPriceWithTax = ListPriceWithTax;
            target.SalePrice        = SalePrice;
            target.SalePriceWithTax = SalePriceWithTax;
            target.Fee                    = Fee;
            target.FeeWithTax             = FeeWithTax;
            target.DiscountAmount         = DiscountAmount;
            target.DiscountAmountWithTax  = DiscountAmountWithTax;
            target.Quantity               = Quantity;
            target.TaxTotal               = TaxTotal;
            target.TaxPercentRate         = TaxPercentRate;
            target.Weight                 = Weight;
            target.Height                 = Height;
            target.Width                  = Width;
            target.MeasureUnit            = MeasureUnit;
            target.WeightUnit             = WeightUnit;
            target.Length                 = Length;
            target.TaxType                = TaxType;
            target.Comment                = Comment;
            target.IsReadOnly             = IsReadOnly;
            target.ValidationType         = ValidationType;
            target.PriceId                = PriceId;
            target.LanguageCode           = LanguageCode;
            target.IsReccuring            = IsReccuring;
            target.IsGift                 = IsGift;
            target.ImageUrl               = ImageUrl;
            target.ProductId              = ProductId;
            target.ProductType            = ProductType;
            target.ShipmentMethodCode     = ShipmentMethodCode;
            target.RequiredShipping       = RequiredShipping;
            target.ProductType            = ProductType;
            target.FulfilmentLocationCode = FulfilmentLocationCode;
            target.FulfillmentCenterId    = FulfillmentCenterId;
            target.FulfillmentCenterName  = FulfillmentCenterName;

            if (!Discounts.IsNullCollection())
            {
                var discountComparer = AbstractTypeFactory <DiscountEntityComparer> .TryCreateInstance();

                Discounts.Patch(target.Discounts, discountComparer, (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }

            if (!TaxDetails.IsNullCollection())
            {
                var taxDetailComparer = AbstractTypeFactory <TaxDetailEntityComparer> .TryCreateInstance();

                TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }
        }
Пример #2
0
		/// <summary>
		/// Patch CatalogBase type
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this LineItemEntity source, LineItemEntity target)
		{
			if (target == null)
				throw new ArgumentNullException("target");

			var patchInjection = new PatchInjection<LineItemEntity>(x => x.Quantity, x => x.SalePrice, x => x.PlacedPrice, x => x.ListPrice, x => x.TaxIncluded, x => x.TaxTotal);
			target.InjectFrom(patchInjection, source);

			if (!source.TaxDetails.IsNullCollection())
			{
				var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name);
				source.TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
			}
		}
Пример #3
0
		public static LineItemEntity ToDataModel(this LineItem lineItem)
		{
			if (lineItem == null)
				throw new ArgumentNullException("lineItem");

			var retVal = new LineItemEntity();
			retVal.InjectFrom(lineItem);
			retVal.Currency = lineItem.Currency.ToString();
			if (lineItem.TaxDetails != null)
			{
				retVal.TaxDetails = new ObservableCollection<TaxDetailEntity>();
				retVal.TaxDetails.AddRange(lineItem.TaxDetails.Select(x => x.ToDataModel()));
			}
			return retVal;
		}
		public static LineItemEntity ToDataModel(this LineItem lineItem, PrimaryKeyResolvingMap pkMap)
		{
			if (lineItem == null)
				throw new ArgumentNullException("lineItem");

			var retVal = new LineItemEntity();
            pkMap.AddPair(lineItem, retVal);

            retVal.InjectFrom(lineItem);
			retVal.Currency = lineItem.Currency.ToString();
			if (lineItem.TaxDetails != null)
			{
				retVal.TaxDetails = new ObservableCollection<TaxDetailEntity>();
				retVal.TaxDetails.AddRange(lineItem.TaxDetails.Select(x => x.ToDataModel()));
			}

            if (lineItem.Discounts != null)
            {
                retVal.Discounts = new ObservableCollection<DiscountEntity>();
                retVal.Discounts.AddRange(lineItem.Discounts.Select(x => x.ToDataModel(pkMap)));
            }
            return retVal;
		}