public static OrderProduct CopyFromModel(this OrderProduct orderRow, CartModel model )
 {
     orderRow.CampaignPrice = model.CampaignPrice;
     orderRow.Count = model.Count;
     var product = Repository.Data.Get<Litium.Domain.Entities.ProductCatalog.Product>(model.ProductId);
     orderRow.Product = product;
     orderRow.ProductName = product.Name;
     orderRow.Price = model.Price;
     orderRow.Summa = model.Summa;
     return orderRow;
 }
Beispiel #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;
        }
Beispiel #3
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 };
 }
Beispiel #4
0
 public ActionResult AddProductToCart( CartModel model )
 {
     CartHelper.Source.AddItemToCart(model);
     return PartialView("PublicSite/MiniCart", CartHelper.Source.GetCartItems());
 }