public ViewResult Index(Сart cart, string returnUrl) { return View(new CartIndexViewModel { Cart = cart, ReturnUrl = returnUrl }); }
public RedirectToRouteResult RemoveFromCart(Сart cart, int id, string returnUrl) { var product = _productService.GetAll().FirstOrDefault(p => p.Id == id); if (product != null) { cart.RemoveLine(product); } return RedirectToAction("Index", new { returnUrl }); }
public RedirectToRouteResult AddToCart(Сart cart, int Id, string returnUrl) { var product = _productService.GetAll() .FirstOrDefault(p => p.Id == Id); if (product != null) { cart.AddItem(product, 1); } return RedirectToAction("Index", new { returnUrl }); }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { Сart cart = (Сart)controllerContext.HttpContext.Session[sessionKey]; if (cart == null) { cart = new Сart(); controllerContext.HttpContext.Session[sessionKey] = cart; } return(cart); }
public ViewResult Checkout(Сart cart, Order order) { if (cart.Lines.Count() == 0) { ModelState.AddModelError("", "Sorry, your cart is empty!"); } if (ModelState.IsValid) { order.OrderDate = DateTime.UtcNow; _orderService.Insert(order); } return View(); }
public PartialViewResult Summary(Сart cart) { return PartialView(cart); }