Пример #1
0
        public static LineItem ToOrderCoreModel(this cartCoreModel.LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException("lineItem");
            }

            var retVal = new LineItem();

            retVal.InjectFrom(lineItem);

            retVal.IsGift                  = lineItem.IsGift;
            retVal.BasePrice               = lineItem.ListPrice;
            retVal.Price                   = lineItem.PlacedPrice;
            retVal.DiscountAmount          = lineItem.DiscountTotal;
            retVal.Tax                     = lineItem.TaxTotal;
            retVal.FulfillmentLocationCode = lineItem.FulfillmentLocationCode;
            retVal.DynamicProperties       = null; //to prevent copy dynamic properties from ShoppingCart LineItem to Order LineItem

            if (lineItem.Discounts != null)
            {
                retVal.Discount = lineItem.Discounts.Select(x => x.ToOrderCoreModel()).FirstOrDefault();
            }
            retVal.TaxDetails = lineItem.TaxDetails;
            return(retVal);
        }
        protected override orderModel.LineItem ToOrderModel(cartModel.LineItem lineItem)
        {
            var cartLineItem2  = lineItem as CartExtModule.Web.Model.CartLineItemExtension;
            var orderLineItem2 = base.ToOrderModel(lineItem) as Model.OrderLineItemExtension;

            if (orderLineItem2 != null)
            {
                orderLineItem2.ProductConfigurationRequestId = cartLineItem2.ProductConfigurationRequestId;
            }

            if (!string.IsNullOrEmpty(cartLineItem2.ProductConfigurationRequestId))
            {
                //ProductConfigurationRequest lineItemCPC = _productConfigurationRequestService.GetByIds(orderLineItem2.ProductConfigurationRequestId).FirstOrDefault();
                //if (lineItemCPC != null)
                //{
                //    lineItemCPC.Id = null;
                //    lineItemCPC.OrderLineItemId = customerOrder.Id; //need to assign the right order id
                //    lineItemCPC.CartLineItemId = null;
                //    lineItemCPC.QuoteLineItemId = null;
                //    lineItemCPC.ProductConfiguration.Id = null;
                //    lineItemCPC.Number = null;
                //    lineItemCPC.Status = "Ordered";
                //    lineItemCPC.CreatedDate = DateTime.UtcNow;
                //    lineItemCPC.ModifiedDate = null;
                //    lineItemCPC.ProductConfiguration.LineItems = lineItemCPC.ProductConfiguration.LineItems.Select(c => { c.Id = null; return c; }).ToList();

                //    var resultCPC = _productConfigurationRequestService.SaveChanges(updateCPCList.ToArray());
                //    extItem.ProductConfigurationRequestId = resultCPC.First().Id;
                //}
            }
            return(orderLineItem2);
        }
Пример #3
0
		public ShipmentItem(LineItem lineItem)
		{
			LineItem = lineItem;
			LineItemId = lineItem.Id;

			Quantity = lineItem.Quantity;
		}
Пример #4
0
		public static LineItem ToCoreModel(this LineItemEntity entity)
		{
			if (entity == null)
				throw new ArgumentNullException("entity");

			var retVal = new LineItem();
			retVal.InjectFrom(entity);
			retVal.Currency = (CurrencyCodes)Enum.Parse(typeof(CurrencyCodes), entity.Currency);
			retVal.TaxDetails = entity.TaxDetails.Select(x => x.ToCoreModel()).ToList();
			return retVal;
		}
		public static LineItem ToCoreModel(this LineItemEntity entity)
		{
			if (entity == null)
				throw new ArgumentNullException("entity");

			var retVal = new LineItem();
			retVal.InjectFrom(entity);
			retVal.Currency = entity.Currency;
			retVal.TaxDetails = entity.TaxDetails.Select(x => x.ToCoreModel()).ToList();
            retVal.Discounts = entity.Discounts.Select(x => x.ToCoreModel()).ToList();
            return retVal;
		}
Пример #6
0
 public static cartCoreModel.LineItem ToCartModel(this coreModel.QuoteItem quoteItem)
 {
     var retVal = new cartCoreModel.LineItem();
     retVal.InjectFrom(quoteItem);
     retVal.Sku = quoteItem.Sku;
     if (quoteItem.SelectedTierPrice != null)
     {
         retVal.PlacedPrice = quoteItem.SelectedTierPrice.Price;
         retVal.Quantity = (int)quoteItem.SelectedTierPrice.Quantity;
      }
     return retVal;
 }
Пример #7
0
        public static cartCoreModel.LineItem ToCartModel(this coreModel.QuoteItem quoteItem)
        {
            var retVal = new cartCoreModel.LineItem();

            retVal.InjectFrom(quoteItem);
            retVal.Sku = quoteItem.Sku;
            if (quoteItem.SelectedTierPrice != null)
            {
                retVal.PlacedPrice = quoteItem.SelectedTierPrice.Price;
                retVal.Quantity    = (int)quoteItem.SelectedTierPrice.Quantity;
            }
            return(retVal);
        }
        protected override VirtoCommerce.Domain.Order.Model.LineItem ToOrderModel(VirtoCommerce.Domain.Cart.Model.LineItem lineItem)
        {
            var result = base.ToOrderModel(lineItem) as Model.LineItem2;

            //Next lines just copy OuterId from cart LineItem2 to order LineItem2
            var cartLineItem2 = lineItem as CartModule2.Model.LineItem2;

            if (cartLineItem2 != null)
            {
                result.OuterId = cartLineItem2.OuterId;
            }
            return(result);
        }
		public static coreModel.LineItem ToCoreModel(this webModel.LineItem cartItem)
		{
			var retVal = new coreModel.LineItem();
			retVal.InjectFrom(cartItem);

			retVal.Currency = cartItem.Currency;

			if(cartItem.Discounts != null)
				retVal.Discounts = cartItem.Discounts.Select(x => x.ToCoreModel()).ToList();

			retVal.TaxDetails = cartItem.TaxDetails;
			return retVal;
		}
Пример #10
0
        public static ShipmentItem ToCoreShipmentItemModel(this cartCoreModel.LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException("lineItem");
            }

            var retVal = new ShipmentItem();

            retVal.InjectFrom(lineItem);

            retVal.LineItem = lineItem.ToCoreModel();
            return(retVal);
        }
        public static webModel.LineItem ToWebModel(this coreModel.LineItem cartItem)
        {
            var retVal = new webModel.LineItem();

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

            retVal.TaxDetails = cartItem.TaxDetails;
            return(retVal);
        }
Пример #12
0
        protected virtual orderModel.LineItem ToOrderModel(cartModel.LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException(nameof(lineItem));
            }

            var retVal = AbstractTypeFactory <orderModel.LineItem> .TryCreateInstance();

            retVal.CreatedDate           = lineItem.CreatedDate;
            retVal.CatalogId             = lineItem.CatalogId;
            retVal.CategoryId            = lineItem.CategoryId;
            retVal.Comment               = lineItem.Note;
            retVal.Currency              = lineItem.Currency;
            retVal.Height                = lineItem.Height;
            retVal.ImageUrl              = lineItem.ImageUrl;
            retVal.IsGift                = lineItem.IsGift;
            retVal.Length                = lineItem.Length;
            retVal.MeasureUnit           = lineItem.MeasureUnit;
            retVal.Name                  = lineItem.Name;
            retVal.PriceId               = lineItem.PriceId;
            retVal.ProductId             = lineItem.ProductId;
            retVal.ProductType           = lineItem.ProductType;
            retVal.Quantity              = lineItem.Quantity;
            retVal.Sku                   = lineItem.Sku;
            retVal.TaxPercentRate        = lineItem.TaxPercentRate;
            retVal.TaxType               = lineItem.TaxType;
            retVal.Weight                = lineItem.Weight;
            retVal.WeightUnit            = lineItem.WeightUnit;
            retVal.Width                 = lineItem.Width;
            retVal.FulfillmentCenterId   = lineItem.FulfillmentCenterId;
            retVal.FulfillmentCenterName = lineItem.FulfillmentCenterName;

            retVal.DiscountAmount = lineItem.DiscountAmount;
            retVal.Price          = lineItem.ListPrice;

            retVal.FulfillmentLocationCode = lineItem.FulfillmentLocationCode;
            retVal.DynamicProperties       = null; //to prevent copy dynamic properties from ShoppingCart LineItem to Order LineItem
            if (lineItem.Discounts != null)
            {
                retVal.Discounts = lineItem.Discounts.Select(ToOrderModel).ToList();
            }
            retVal.TaxDetails = lineItem.TaxDetails;
            return(retVal);
        }
Пример #13
0
        public static LineItem ToCoreModel(this cartCoreModel.LineItem lineItem)
        {
            if (lineItem == null)
            {
                throw new ArgumentNullException("lineItem");
            }

            var retVal = new LineItem();

            retVal.InjectFrom(lineItem);

            retVal.IsGift    = lineItem.IsGift;
            retVal.BasePrice = lineItem.ListPrice;
            retVal.Price     = lineItem.PlacedPrice;
            retVal.Tax       = lineItem.TaxTotal;
            retVal.FulfillmentLocationCode = lineItem.FulfillmentLocationCode;

            if (lineItem.Discounts != null)
            {
                retVal.Discount = lineItem.Discounts.Select(x => x.ToCoreModel()).FirstOrDefault();
            }
            retVal.TaxDetails = lineItem.TaxDetails;
            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);
        }
Пример #15
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);
        }
Пример #16
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;
        }