public ViewResult Index(Cart cart, string returnUrl) { return View(new CartIndexViewModel { Cart = cart, ReturnUrl = returnUrl }); }
public RedirectToRouteResult RemoveFromCart(Cart cart, int songId, string returnUrl) { Song song = repository.Songs .FirstOrDefault(s => s.SongID == songId); if (song != null) { cart.RemoveLine(song); } return RedirectToAction("Index", new { returnUrl }); }
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; }
public ViewResult Checkout(Cart cart, CustomerDetails customerDetails) { if (cart.Lines.Count() == 0) { ModelState.AddModelError("", "Sorry your cart is empty!"); } if (ModelState.IsValid) { cart.Clear(); return View("Completed"); } else { return View(customerDetails); } }
private Cart GetCart() { Cart cart = (Cart)Session["Cart"]; if (cart == null) { cart = new Cart(); Session["Cart"] = cart; } return cart; }
public PartialViewResult Summary(Cart cart) { return PartialView(cart); }