Пример #1
0
 public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
 {
     Cart cart = (Cart)controllerContext.HttpContext.Session[sessionKey];
     if (cart == null)
     {
         cart = new Cart();
         controllerContext.HttpContext.Session[sessionKey] = cart;
     }
     return cart;
 }
Пример #2
0
 public RedirectToRouteResult RemoveFromCart(Cart cart, int productID, string returnUrl)
 {
     Products product = repository.Products.FindById(productID);
     if (product == null)
         throw new HttpException(404, "Not found");
     if (product != null)
     {
         cart.RemoveLine(product);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
Пример #3
0
 public RedirectToRouteResult AddToCart(Cart cart, int productID, string returnUrl, int quantity = 1)
 {
     Products product = repository.Products.FindById(productID);
     if(product==null)
         throw new HttpException(404, "Not found");
     if (product != null)
     {
         cart.AddItem(product, quantity);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
Пример #4
0
 public ViewResult Summary(Cart cart)
 {
     return View(cart);
 }
Пример #5
0
 public ViewResult Index(Cart cart, string returnUrl)
 {
     return View(new CartIndexViewModel { Cart = cart, ReturnUrl = returnUrl });
 }