Exemplo n.º 1
0
 public virtual ActionResult Add(ItemViewModel item)
 {
     var model = Session["cart"] as CartViewModel ?? new CartViewModel();
     //Check if Item already in cart.
     var existingItem = (from i in model.Items where i.Sku == item.Sku select i).FirstOrDefault();
     if(existingItem == null)
     {
         model.Items.Add(item);
     }
     else
     {
         existingItem.Quantity += item.Quantity;
     }
     model.TotalPrice += item.Price * item.Quantity;
     Session["cart"] = model;
     return View(MVC.Shared.Views.Partial.QuickCart, model);
 }
Exemplo n.º 2
0
 public virtual JsonResult GetDefault()
 {
     var model = new ItemViewModel {Sku = "test", Price = 10.00, Size = "Small", Quantity = 0};
     return Json(model);
 }