Esempio n. 1
0
        public static AbbigliamentoECommerceEntity.Cart ConvertCartModelTOCartEntity(Cart pCart)
        {
            AbbigliamentoECommerceEntity.Cart wCart = new AbbigliamentoECommerceEntity.Cart();

            wCart.listProduct = new List <AbbigliamentoECommerceEntity.CartDetail>();
            foreach (DetailCart wCartDetail in pCart.DetailsCart)
            {
                AbbigliamentoECommerceEntity.CartDetail wDetailCart = new AbbigliamentoECommerceEntity.CartDetail();
                wDetailCart.quantita      = wCartDetail.Quantity;
                wDetailCart.singleProduct = ProductEntityToProductModel.ConvertoProdyctEntityTOProductModel(wCartDetail.Product);
                wCart.listProduct.Add(wDetailCart);
            }
            return(wCart);
        }
Esempio n. 2
0
        public static Cart ConvertoCartEntityTOCartModel(AbbigliamentoECommerceEntity.Cart pCart)
        {
            Cart wCart = new Cart();

            wCart.ShippingCost = 5.00;
            wCart.TotalPrice   = pCart.listProduct.Sum(p => p.quantita * p.singleProduct.prezzo);
            wCart.Vat          = 1.06;
            wCart.DetailsCart  = new List <DetailCart>();
            foreach (AbbigliamentoECommerceEntity.CartDetail wCartDetail in pCart.listProduct)
            {
                DetailCart wDetailCart = new DetailCart();
                wDetailCart.Quantity   = wCartDetail.quantita;
                wDetailCart.Quantities = new Dictionary <int, int>();
                for (int i = 0; i < wCartDetail.singleProduct.Quantity; i++)
                {
                    wDetailCart.Quantities.Add(i, i + 1);
                }
                wDetailCart.Product = ProductEntityToProductModel.ConvertoProdyctEntityTOProductModel(wCartDetail.singleProduct);
                wCart.DetailsCart.Add(wDetailCart);
            }
            return(wCart);
        }