Пример #1
0
        public static Shipment ToOrderCoreModel(this cartCoreModel.Shipment shipment)
        {
            var retVal = new Shipment();

            retVal.InjectFrom(shipment);
            retVal.Currency       = shipment.Currency;
            retVal.Sum            = shipment.Total;
            retVal.Tax            = shipment.TaxTotal;
            retVal.DiscountAmount = shipment.DiscountTotal;
            retVal.Status         = "New";
            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress = shipment.DeliveryAddress.ToCoreModel();
            }
            if (shipment.Items != null)
            {
                retVal.Items = shipment.Items.Select(x => x.ToOrderCoreModel()).ToList();
            }
            if (shipment.Discounts != null)
            {
                retVal.Discount = shipment.Discounts.Select(x => x.ToOrderCoreModel()).FirstOrDefault();
            }
            retVal.TaxDetails = shipment.TaxDetails;
            return(retVal);
        }
Пример #2
0
        protected virtual orderModel.Shipment ToOrderModel(cartModel.Shipment shipment)
        {
            var retVal = AbstractTypeFactory <orderModel.Shipment> .TryCreateInstance();

            retVal.Currency              = shipment.Currency;
            retVal.DiscountAmount        = shipment.DiscountAmount;
            retVal.Height                = shipment.Height;
            retVal.Length                = shipment.Length;
            retVal.MeasureUnit           = shipment.MeasureUnit;
            retVal.FulfillmentCenterId   = shipment.FulfillmentCenterId;
            retVal.FulfillmentCenterName = shipment.FulfillmentCenterName;
            retVal.ShipmentMethodCode    = shipment.ShipmentMethodCode;
            retVal.ShipmentMethodOption  = shipment.ShipmentMethodOption;
            retVal.Sum            = shipment.Total;
            retVal.Weight         = shipment.Weight;
            retVal.WeightUnit     = shipment.WeightUnit;
            retVal.Width          = shipment.Width;
            retVal.TaxPercentRate = shipment.TaxPercentRate;
            retVal.DiscountAmount = shipment.DiscountAmount;
            retVal.Price          = shipment.Price;
            retVal.Status         = "New";
            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress     = shipment.DeliveryAddress;
                retVal.DeliveryAddress.Key = null;
            }
            if (shipment.Discounts != null)
            {
                retVal.Discounts = shipment.Discounts.Select(ToOrderModel).ToList();
            }
            retVal.TaxDetails = shipment.TaxDetails;
            return(retVal);
        }
        protected override orderModel.Shipment ToOrderModel(cartModel.Shipment shipment)
        {
            var shipment2 = base.ToOrderModel(shipment) as Model.ShipmentExtension;

            if (shipment2 != null)
            {
                shipment2.HasLoadingDock = shipment2.HasLoadingDock;
                shipment2.IsCommercial   = shipment2.IsCommercial;
                shipment2.Comment        = shipment2.Comment;
            }
            return(shipment2);
        }
Пример #4
0
		public static coreModel.Shipment ToCoreModel(this webModel.Shipment shipment)
		{
			var retVal = new coreModel.Shipment();
			retVal.InjectFrom(shipment);
		
			retVal.Currency = shipment.Currency;
		
			if (shipment.DeliveryAddress != null)
				retVal.DeliveryAddress = shipment.DeliveryAddress.ToCoreModel();
			if(shipment.Discounts != null)
				retVal.Discounts = shipment.Discounts.Select(x => x.ToCoreModel()).ToList();
			if (shipment.Items != null)
				retVal.Items = shipment.Items.Select(x => x.ToCoreModel()).ToList();

			retVal.TaxDetails = shipment.TaxDetails;
			return retVal;
		}
        public static Shipment ToCoreModel(this cartCoreModel.Shipment shipment)
        {
            var retVal = new Shipment();

            retVal.InjectFrom(shipment);
            retVal.Currency = shipment.Currency;
            retVal.Sum      = shipment.ShippingPrice;
            retVal.Tax      = shipment.TaxTotal;

            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress = shipment.DeliveryAddress.ToCoreModel();
            }
            if (shipment.Items != null)
            {
                retVal.Items = shipment.Items.Select(x => x.ToCoreShipmentItemModel()).ToList();
            }
            retVal.TaxDetails = shipment.TaxDetails;
            return(retVal);
        }
Пример #6
0
		public static Shipment ToCoreModel(this ShipmentEntity entity)
		{
			if (entity == null)
				throw new ArgumentNullException("entity");

			var retVal = new Shipment();
			retVal.InjectFrom(entity);
			
			retVal.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);
			if (entity.Addresses != null && entity.Addresses.Any())
			{
				retVal.DeliveryAddress = entity.Addresses.First().ToCoreModel();
			}
					
			if (entity.Items != null)
			{
				retVal.Items = entity.Items.Select(x => x.ToCoreModel()).ToList();
			}
			retVal.TaxDetails = entity.TaxDetails.Select(x => x.ToCoreModel()).ToList();
			return retVal;
		}
Пример #7
0
        public static webModel.Shipment ToWebModel(this coreModel.Shipment shipment)
        {
            var retVal = new webModel.Shipment();

            retVal.InjectFrom(shipment);
            retVal.Currency = shipment.Currency;
            if (shipment.DeliveryAddress != null)
            {
                retVal.DeliveryAddress = shipment.DeliveryAddress.ToWebModel();
            }
            if (shipment.Discounts != null)
            {
                retVal.Discounts = shipment.Discounts.Select(x => x.ToWebModel()).ToList();
            }
            if (shipment.Items != null)
            {
                retVal.Items = shipment.Items.Select(x => x.ToWebModel()).ToList();
            }

            retVal.TaxDetails = shipment.TaxDetails;
            return(retVal);
        }
        public static cartCoreModel.ShoppingCart ToCartModel(this coreModel.QuoteRequest quoteRequest)
        {
            var retVal = new cartCoreModel.ShoppingCart();
            retVal.InjectFrom(quoteRequest);
            retVal.Currency = quoteRequest.Currency;
            if (quoteRequest.Items != null)
            {
                retVal.Items = quoteRequest.Items.Select(x => x.ToCartModel()).ToList();
            }

            if(quoteRequest.ShipmentMethod != null)
            {
                var shipment = new cartCoreModel.Shipment
                {
                    Currency = quoteRequest.Currency,
                    ShipmentMethodCode = quoteRequest.ShipmentMethod.ShipmentMethodCode,
                    ShipmentMethodOption = quoteRequest.ShipmentMethod.OptionName                     
                };
                retVal.Shipments = new List<cartCoreModel.Shipment>(new[] { shipment });
            }

            return retVal;
        }
Пример #9
0
        public static cartCoreModel.ShoppingCart ToCartModel(this coreModel.QuoteRequest quoteRequest)
        {
            var retVal = new cartCoreModel.ShoppingCart();

            retVal.InjectFrom(quoteRequest);
            retVal.Currency = quoteRequest.Currency;
            if (quoteRequest.Items != null)
            {
                retVal.Items = quoteRequest.Items.Select(x => x.ToCartModel()).ToList();
            }

            if (quoteRequest.ShipmentMethod != null)
            {
                var shipment = new cartCoreModel.Shipment
                {
                    Currency             = quoteRequest.Currency,
                    ShipmentMethodCode   = quoteRequest.ShipmentMethod.ShipmentMethodCode,
                    ShipmentMethodOption = quoteRequest.ShipmentMethod.OptionName
                };
                retVal.Shipments = new List <cartCoreModel.Shipment>(new[] { shipment });
            }

            return(retVal);
        }
        private static ShoppingCart GetInvalidTestCart(string id)
        {
            var cart = new ShoppingCart
            {
                Id          = id,
                Currency    = "USD",
                CustomerId  = "Test Customer",
                StoreId     = "test store",
                CreatedDate = DateTime.Now,
                Addresses   = new[]
                {
                    new CartAddress {
                        AddressType  = CartAddressType.Shipping,
                        Phone        = "+68787687",
                        PostalCode   = "19142",
                        CountryCode  = "US",
                        CountryName  = "United states",
                        Email        = "*****@*****.**",
                        FirstName    = "first name",
                        LastName     = "last name",
                        Line1        = "6025 Greenway Ave",
                        City         = "Philadelphia",
                        RegionId     = "PA",
                        RegionName   = "Pennsylvania",
                        Organization = "org1"
                    }
                }.ToList(),
                Discounts = new[] { new CartDiscount
                                    {
                                        PromotionId    = "testPromotion",
                                        Currency       = "USD",
                                        DiscountAmount = 12,
                                    } },
                Coupon = "ssss"
            };
            var item1 = new CartLineItem
            {
                Id                 = Guid.NewGuid().ToString(),
                ListPrice          = 10,
                ExtendedPrice      = 20,
                ProductId          = "shoes",
                CatalogId          = "catalog",
                Currency           = "USD",
                CategoryId         = "category",
                Name               = "shoes",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "itemPromotion",
                        Currency       = "USD",
                        DiscountAmount = 12
                    }
                }
            };
            var item2 = new CartLineItem
            {
                Id                 = Guid.NewGuid().ToString(),
                ListPrice          = 100,
                ExtendedPrice      = 200,
                ProductId          = "t-shirt",
                CatalogId          = "catalog",
                CategoryId         = "category",
                Currency           = "USD",
                Name               = "t-shirt",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = "USD",
                        DiscountAmount = 12
                    }
                }
            };

            cart.Items = new List <CartLineItem> {
                item1, item2
            };

            var shipment = new CartShipment
            {
                Id              = Guid.NewGuid().ToString(),
                Currency        = "USD",
                DeliveryAddress = new CartAddress
                {
                    City         = "Philadelphia",
                    CountryName  = "United states",
                    Phone        = "+68787687",
                    PostalCode   = "19142",
                    CountryCode  = "US",
                    Email        = "*****@*****.**",
                    FirstName    = "first name",
                    LastName     = "last name",
                    Line1        = "6025 Greenway Ave",
                    RegionId     = "PA",
                    RegionName   = "Pennsylvania",
                    Organization = "org1"
                },
                Discounts = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = "USD",
                        DiscountAmount = 12,
                    }
                }
            };

            cart.Shipments = new List <CartShipment> {
                shipment
            };

            var payment = new CartPayment
            {
                Id = Guid.NewGuid().ToString(),
                PaymentGatewayCode = "PayPal",
                Currency           = "USD",
                Amount             = 10,
                OuterId            = "et"
            };

            cart.Payments = new List <CartPayment> {
                payment
            };

            return(cart);
        }
Пример #11
0
        private static ShoppingCart GetTestCart(string id)
        {
            var cart = new ShoppingCart
            {
                Id          = id,
                Currency    = CurrencyCodes.USD,
                CustomerId  = "Test Customer",
                StoreId     = "test store",
                CreatedDate = DateTime.Now,
                Addresses   = new[]
                {
                    new CartAddress {
                        AddressType  = CartAddressType.Shipping,
                        Phone        = "+68787687",
                        PostalCode   = "60602",
                        CountryCode  = "US",
                        CountryName  = "United states",
                        Email        = "*****@*****.**",
                        FirstName    = "first name",
                        LastName     = "last name",
                        Line1        = "45 Fremont Street",
                        City         = "Los Angeles",
                        RegionId     = "CA",
                        Organization = "org1"
                    }
                }.ToList(),
                Discounts = new[] { new CartDiscount
                                    {
                                        PromotionId    = "testPromotion",
                                        Currency       = CurrencyCodes.USD,
                                        DiscountAmount = 12,
                                    } },
                Coupon = new CartCoupon
                {
                    CouponCode = "ssss"
                }
            };
            var item1 = new CartLineItem
            {
                ListPrice          = 10,
                ExtendedPrice      = 20,
                ProductId          = "shoes",
                CatalogId          = "catalog",
                Currency           = CurrencyCodes.USD,
                CategoryId         = "category",
                Name               = "shoes",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "itemPromotion",
                        Currency       = CurrencyCodes.USD,
                        DiscountAmount = 12
                    }
                }
            };
            var item2 = new CartLineItem
            {
                ListPrice          = 100,
                ExtendedPrice      = 200,
                ProductId          = "t-shirt",
                CatalogId          = "catalog",
                CategoryId         = "category",
                Currency           = CurrencyCodes.USD,
                Name               = "t-shirt",
                Quantity           = 2,
                ShipmentMethodCode = "EMS",
                Discounts          = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = CurrencyCodes.USD,
                        DiscountAmount = 12
                    }
                }
            };

            cart.Items = new List <CartLineItem> {
                item1, item2
            };

            var shipment = new CartShipment
            {
                Currency        = CurrencyCodes.USD,
                DeliveryAddress = new CartAddress
                {
                    City         = "london",
                    CountryName  = "England",
                    Phone        = "+68787687",
                    PostalCode   = "2222",
                    CountryCode  = "ENG",
                    Email        = "*****@*****.**",
                    FirstName    = "first name",
                    LastName     = "last name",
                    Line1        = "line 1",
                    Organization = "org1"
                },
                Discounts = new[] {
                    new CartDiscount
                    {
                        PromotionId    = "testPromotion",
                        Currency       = CurrencyCodes.USD,
                        DiscountAmount = 12,
                    }
                }
            };

            cart.Shipments = new List <CartShipment> {
                shipment
            };

            var payment = new CartPayment
            {
                PaymentGatewayCode = "PayPal",
                Currency           = CurrencyCodes.USD,
                Amount             = 10,
                OuterId            = "et"
            };

            cart.Payments = new List <CartPayment> {
                payment
            };

            return(cart);
        }
Пример #12
0
        private static ShoppingCart GetTestCart(string id)
        {
            var cart = new ShoppingCart
            {
                Id = id,
                Currency = CurrencyCodes.USD,
                CustomerId = "Test Customer",
                StoreId = "test store",
                CreatedDate = DateTime.Now,
                Addresses = new[]
				{
					new CartAddress {	
					AddressType = CartAddressType.Shipping, 
					Phone = "+68787687",
					PostalCode = "60602",
					CountryCode = "US",
					CountryName = "United states",
					Email = "*****@*****.**",
					FirstName = "first name",
					LastName = "last name",
					Line1 = "45 Fremont Street",
                    City = "Los Angeles",
                    RegionId = "CA",
					Organization = "org1"
					}
				}.ToList(),
                Discounts = new[] { new CartDiscount
                    {
                        PromotionId = "testPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12,
                        
                    }
                },
                Coupon = new CartCoupon
                {
                    CouponCode = "ssss"
                }
                
            };
            var item1 = new CartLineItem
            {
                ListPrice = 10,
                ExtendedPrice = 20,
                ProductId = "shoes",
                CatalogId = "catalog",
                Currency = CurrencyCodes.USD,
                CategoryId = "category",
                Name = "shoes",
                Quantity = 2,
                ShipmentMethodCode = "EMS",
                Discounts = new[] { 
                    new CartDiscount
                    {
                        PromotionId = "itemPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12
                        
                    }
                }
            };
            var item2 = new CartLineItem
            {
                ListPrice = 100,
                ExtendedPrice = 200,
                ProductId = "t-shirt",
                CatalogId = "catalog",
                CategoryId = "category",
                Currency = CurrencyCodes.USD,
                Name = "t-shirt",
                Quantity = 2,
                ShipmentMethodCode = "EMS",
                Discounts = new[]{ 
                    new CartDiscount
                    {
                        PromotionId = "testPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12
                    }
                }
            };
            cart.Items = new List<CartLineItem> { item1, item2 };

            var shipment = new CartShipment
            {
                Currency = CurrencyCodes.USD,
                DeliveryAddress = new CartAddress
                {
                    City = "london",
                    CountryName = "England",
                    Phone = "+68787687",
                    PostalCode = "2222",
                    CountryCode = "ENG",
                    Email = "*****@*****.**",
                    FirstName = "first name",
                    LastName = "last name",
                    Line1 = "line 1",
                    Organization = "org1"
                },
                Discounts = new[] {
                    new CartDiscount
                    {
                        PromotionId = "testPromotion",
                        Currency = CurrencyCodes.USD,
                        DiscountAmount = 12,
                        
                    }
                }
            };
            cart.Shipments = new List<CartShipment> { shipment };

            var payment = new CartPayment
            {
                PaymentGatewayCode = "PayPal",
                Currency = CurrencyCodes.USD,
                Amount = 10,
                OuterId = "et"
            };
            cart.Payments = new List<CartPayment> { payment };

            return cart;
        }