public ActionResult CartSummary() { var cart = new ShoppingCartService(HttpContext); ViewData["CartCount"] = cart.Count(); return PartialView("CartSummary"); }
public ActionResult AddToCart(int id) { var cart = new ShoppingCartService(HttpContext); cart.Add(id); return RedirectToAction("index"); }
// GET: ShoppingCart public ActionResult Index() { var cart = new ShoppingCartService(HttpContext); var items = cart.GetCartItems(); return View(new ShoppingCartViewModel { Items = items, Total = CalcuateCart(items) }); }
public ActionResult Checkout(CheckoutViewModel model) { if (!ModelState.IsValid) { return View(model); } var cart = new ShoppingCartService(HttpContext); var result = cart.Checkout(model); if (result.Message=="Pass") { TempData["transactionId"] = result.TransactionId; cart.ClearCart(HttpContext); return RedirectToAction("Complete"); } ModelState.AddModelError(string.Empty, result.Message); return View(model); }
public ActionResult RemoveFromCart(int id) { var cart = new ShoppingCartService(HttpContext); cart.Remove(id); return RedirectToAction("index"); }