//cart получаем из CartModelBinder public RedirectToActionResult AddToCart(Cart cart, int gameId, string returnUrl) { Game game = _repository.Games.FirstOrDefault(g => g.GameId == gameId); if (game != null) { cart.AddItem(game, 1); CartModelBinder.SetUpCart(cart, HttpContext.Session); } return(RedirectToAction("Index", new { returnUrl })); }
public RedirectToActionResult RemoveFromCart(Cart cart, int gameId, string returnUrl) { Game game = _repository.Games.FirstOrDefault(g => g.GameId == gameId); if (game != null) { cart.RemoveLine(game); if (HttpContext != null) { CartModelBinder.SetUpCart(cart, HttpContext.Session); } } return(RedirectToAction("Index", new { returnUrl })); }
public ViewResult Checkout(Cart cart, ShippingDetails shippingDetails) { if (cart.Lines.Count() == 0) { ModelState.AddModelError("", "Извените ваша корзина пуста"); } if (ModelState.IsValid) { _processor.ProcessOrder(cart, shippingDetails); cart.Clear(); if (HttpContext != null) { CartModelBinder.SetUpCart(cart, HttpContext.Session); } return(View("Completed")); } else { return(View(shippingDetails)); } }