Example #1
0
 private CartModel CombineCartItems(CartModel current, CartModel model)
 {
     return(new CartModel {
         ProductId = model.ProductId,
         CampaignPrice = model.CampaignPrice,
         Price = model.Price,
         ProductName = model.ProductName,
         Count = model.Count + current.Count,
         Summa = model.CalculateSumma().Summa + current.CalculateSumma().Summa
     });
 }
Example #2
0
        public void AddItemToCart(CartModel model)
        {
            var order = HttpContext.Current.Session[WebStroreResource.CART] as OrderModel ?? new OrderModel();

            if (order.OrderRows.Contains(model, new CartComparer()))
            {
                CartModel current = order.OrderRows.FirstOrDefault(x => x.ProductId == model.ProductId);
                order.OrderRows.Add(CombineCartItems(current, model));
                order.OrderRows.Remove(current);
            }
            else
            {
                order.OrderRows.Add(model.CalculateSumma());
            }

            HttpContext.Current.Session[WebStroreResource.CART] = order;
        }
Example #3
0
        public void AddItemToCart(CartModel model)
        {
            var order = HttpContext.Current.Session[WebStroreResource.CART] as OrderModel ?? new OrderModel();

            if (order.OrderRows.Contains(model, new CartComparer()))
            {
                CartModel current = order.OrderRows.FirstOrDefault(x => x.ProductId == model.ProductId);
                order.OrderRows.Add(CombineCartItems(current, model));
                order.OrderRows.Remove(current);
            }
            else
            {
                order.OrderRows.Add(model.CalculateSumma());
            }

            HttpContext.Current.Session[WebStroreResource.CART] = order;
        }
Example #4
0
 private CartModel CombineCartItems(CartModel current, CartModel model)
 {
     return new CartModel {
         ProductId = model.ProductId,
         CampaignPrice = model.CampaignPrice,
         Price = model.Price,
         ProductName = model.ProductName,
         Count = model.Count + current.Count,
         Summa = model.CalculateSumma().Summa + current.CalculateSumma().Summa };
 }