/// <summary>
		/// Patch CatalogBase type
		/// </summary>
		/// <param name="source"></param>
		/// <param name="target"></param>
		public static void Patch(this ShipmentEntity source, ShipmentEntity target)
		{
			if (target == null)
				throw new ArgumentNullException("target");

			var patchInjection = new PatchInjection<ShipmentEntity>(x => x.ShippingPrice, x => x.TaxTotal,
																		   x => x.TaxIncluded, x => x.Currency,
																		   x => x.WeightUnit, x => x.WeightValue,
																		   x => x.DimensionHeight, x => x.DimensionLength, x => x.DimensionUnit,
																		   x => x.DimensionWidth, x => x.TaxType);
			target.InjectFrom(patchInjection, source);

		
			if (!source.Addresses.IsNullCollection())
			{
				source.Addresses.Patch(target.Addresses, new AddressComparer(), (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
			}
			if (source.Items != null)
			{
				source.Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
			}
			if (!source.TaxDetails.IsNullCollection())
			{
				var taxDetailComparer = AnonymousComparer.Create((TaxDetailEntity x) => x.Name);
				source.TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
			}
            if (!source.Discounts.IsNullCollection())
            {
                source.Discounts.Patch(target.Discounts, new DiscountComparer(), (sourceDiscount, targetDiscount) => sourceDiscount.Patch(targetDiscount));
            }
        }
		public static ShipmentEntity ToDataModel(this Shipment shipment, ShoppingCartEntity cartEntity, PrimaryKeyResolvingMap pkMap)
		{
			if (shipment == null)
				throw new ArgumentNullException("shipment");

			var retVal = new ShipmentEntity();
            pkMap.AddPair(shipment, retVal);

            retVal.InjectFrom(shipment);
	
			retVal.Currency = shipment.Currency.ToString();
		
			if (shipment.DeliveryAddress != null)
			{
				retVal.Addresses = new ObservableCollection<AddressEntity>(new AddressEntity[] { shipment.DeliveryAddress.ToDataModel() });
			}
			if (shipment.Items != null)
			{
				retVal.Items = new ObservableCollection<ShipmentItemEntity>(shipment.Items.Select(x => x.ToDataModel(cartEntity, pkMap)));
			}
			if (shipment.TaxDetails != null)
			{
				retVal.TaxDetails = new ObservableCollection<TaxDetailEntity>();
				retVal.TaxDetails.AddRange(shipment.TaxDetails.Select(x => x.ToDataModel()));
			}
            if (shipment.Discounts != null)
            {
                retVal.Discounts = new ObservableCollection<DiscountEntity>();
                retVal.Discounts.AddRange(shipment.Discounts.Select(x => x.ToDataModel(pkMap)));
            }
            return retVal;
		}
		public static ShipmentEntity ToDataModel(this Shipment shipment)
		{
			if (shipment == null)
				throw new ArgumentNullException("shipment");

			var retVal = new ShipmentEntity();
			retVal.InjectFrom(shipment);
	
			retVal.Currency = shipment.Currency.ToString();
		
			if (shipment.DeliveryAddress != null)
			{
				retVal.Addresses = new ObservableCollection<AddressEntity>(new AddressEntity[] { shipment.DeliveryAddress.ToDataModel() });
			}
			if (shipment.Items != null)
			{
				retVal.Items = new ObservableCollection<LineItemEntity>(shipment.Items.Select(x => x.ToDataModel()));
			}
			if (shipment.TaxDetails != null)
			{
				retVal.TaxDetails = new ObservableCollection<TaxDetailEntity>();
				retVal.TaxDetails.AddRange(shipment.TaxDetails.Select(x => x.ToDataModel()));
			}
			return retVal;
		}
Exemple #4
0
        public virtual void Patch(ShipmentEntity target)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            target.Fee                   = Fee;
            target.FeeWithTax            = FeeWithTax;
            target.FulfillmentCenterId   = FulfillmentCenterId;
            target.FulfillmentCenterName = FulfillmentCenterName;
            target.ShipmentMethodCode    = ShipmentMethodCode;
            target.Total                 = Total;
            target.TotalWithTax          = TotalWithTax;
            target.TaxTotal              = TaxTotal;
            target.Price                 = Price;
            target.PriceWithTax          = PriceWithTax;
            target.DiscountAmount        = DiscountAmount;
            target.DiscountAmountWithTax = DiscountAmountWithTax;
            target.TaxPercentRate        = TaxPercentRate;
            target.TaxIncluded           = TaxIncluded;
            target.Currency              = Currency;
            target.WeightUnit            = WeightUnit;
            target.WeightValue           = WeightValue;
            target.DimensionHeight       = DimensionHeight;
            target.DimensionLength       = DimensionLength;
            target.DimensionUnit         = DimensionUnit;
            target.DimensionWidth        = DimensionWidth;
            target.TaxType               = TaxType;
            target.ShipmentMethodOption  = ShipmentMethodOption;

            if (!Addresses.IsNullCollection())
            {
                Addresses.Patch(target.Addresses, (sourceAddress, targetAddress) => sourceAddress.Patch(targetAddress));
            }

            if (!Items.IsNullCollection())
            {
                Items.Patch(target.Items, (sourceItem, targetItem) => sourceItem.Patch(targetItem));
            }

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

                TaxDetails.Patch(target.TaxDetails, taxDetailComparer, (sourceTaxDetail, targetTaxDetail) => sourceTaxDetail.Patch(targetTaxDetail));
            }

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

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

            if (!DynamicPropertyObjectValues.IsNullCollection())
            {
                DynamicPropertyObjectValues.Patch(target.DynamicPropertyObjectValues, (sourceDynamicPropertyObjectValues, targetDynamicPropertyObjectValues) => sourceDynamicPropertyObjectValues.Patch(targetDynamicPropertyObjectValues));
            }
        }
Exemple #5
0
        public void Tst1()
        {
            var repository = new CartRepositoryImpl("VirtoCommerce", new AuditableInterceptor(),
                                                    new EntityPrimaryKeyGeneratorInterceptor());
            var cart = new dataModel.ShoppingCartEntity
            {
                StoreId    = "ss",
                CustomerId = "ss",
                Currency   = "ss",
            };

            var shipment = new dataModel.ShipmentEntity
            {
                Currency = "sss",
            };

            cart.Shipments.Add(shipment);
            repository.Add(cart);
            repository.UnitOfWork.Commit();
        }
		public void Tst1()
		{
			var repository = new CartRepositoryImpl("VirtoCommerce", new AuditableInterceptor(),
															   new EntityPrimaryKeyGeneratorInterceptor());
			var cart = new dataModel.ShoppingCartEntity
			{
				StoreId = "ss",
				CustomerId = "ss",
				Currency = "ss",

			};

			var shipment = new dataModel.ShipmentEntity
			{
				Currency = "sss",

			};
			cart.Shipments.Add(shipment);
			repository.Add(cart);
			repository.UnitOfWork.Commit();
		}