示例#1
0
 public ViewResult Index(Cart cart , string returnUrl)
 {
     return View(new CartIndexViewModel
     {
         Cart = cart,
         ReturnUrl = returnUrl
     });
 }
示例#2
0
 public RedirectToRouteResult RemoveFromCart(Cart cart, int productID, string returnUrl)
 {
     Product product = repository.Products
         .FirstOrDefault(p => p.ProductID == productID);
     if (product != null)
     {
         cart.RemoveLine(product);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
示例#3
0
 public RedirectToRouteResult AddToCart(Cart cart, int productId, string returnUrl)
 {
     Product product = repository.Products
         .FirstOrDefault(p => p.ProductID == productId);
     if (product != null)
     {
         cart.AddItem(product, 1);
     }
     return RedirectToAction("Index", new { returnUrl });
 }
示例#4
0
 public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
 {
     //get the cart from the session
     Cart cart = (Cart)controllerContext.HttpContext.Session[sessionKey];
     //create the cart if there was none in the session data
     if (cart == null)
     {
         cart = new Cart();
         controllerContext.HttpContext.Session[sessionKey] = cart;
     }
     //return the cart
     return cart;
 }
示例#5
0
 public PartialViewResult Summary(Cart cart)
 {
     return PartialView(cart);
 }