Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ClearCart()
        {
            await _Cart.ClearCartAsync();

            return(RedirectToAction("Index"));
        }