public async Task<ActionResult> RemoveFromCart(int id) { var cart = new ShoppingCart(HttpContext); await cart.RemoveAsync(id); return RedirectToAction("index"); }
// GET: ShoppingCart public async Task<ActionResult> Index() { var cart = new ShoppingCart(HttpContext); var items = await cart.GetCartItemsAsync(); return View(new ShoppingCartViewModel { Items = items, Total = CalcuateCart(items) }); }
public async Task<ActionResult> Checkout(CheckoutViewModel model) { if (!ModelState.IsValid) { return View(model); } var cart = new ShoppingCart(HttpContext); var result = await cart.CheckoutAsync(model); return RedirectToAction("index"); }
public async Task<ActionResult> Checkout(CheckoutViewModel model) { if (!ModelState.IsValid) { return View(model); } var cart = new ShoppingCart(HttpContext); var result = await cart.CheckoutAsync(model); if (result.Succeeded) { TempData["transactionId"] = result.TransactionId; return RedirectToAction("Complete"); } ModelState.AddModelError(string.Empty, result.Message); return View(model); }