public async Task <IActionResult> Checkout(OrderModel order) { var userId = _userMnger.GetUserId(HttpContext.User); order.UserId = userId; var products = await _cart.GetCartItemAsync(); _cart.cart = products; if (_cart.cart.Count == 0) { ModelState.AddModelError("", "Add Pizza First"); } if (ModelState.IsValid) { await _orderRepo.CreateOrderAsync(order); await _cart.ClearCartAsync(); return(RedirectToAction("Thanks")); } return(View(order)); }
public async Task <IActionResult> ClearCart() { await _Cart.ClearCartAsync(); return(RedirectToAction("Index")); }