Пример #1
0
 public RedirectToRouteResult RemoveFromCart(Cart cart,int itemId, string returnUrl)
 {
     Item item = db.Items.SingleOrDefault(i => i.ItemId == itemId);
     if (item != null)
     {
         cart.RemoveLine(item);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
Пример #2
0
 public RedirectToRouteResult AddToCart(Cart cart, int itemId, string returnUrl)
 {
     Item item = db.Items.SingleOrDefault(i => i.ItemId == itemId);
     if (item != null)
     {
         cart.AddItem(item, 1);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
Пример #3
0
 public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
 {
     Cart cart = null;
     if (controllerContext.HttpContext.Session != null)
     {
         cart = (Cart)controllerContext.HttpContext.Session[sessionKey];
     }
     if (cart == null)
     {
         cart = new Cart();
         if (controllerContext.HttpContext.Session != null)
         {
             controllerContext.HttpContext.Session[sessionKey] = cart;
         }
     }
     return cart;
 }
Пример #4
0
 public PartialViewResult Summary(Cart cart)
 {
     return PartialView(cart);
 }
Пример #5
0
 public ViewResult Index(Cart cart, string returnUrl)
 {
     return View(new CartIndexViewModel { Cart = cart, ReturnUrl = returnUrl });
 }