예제 #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 });
 }