コード例 #1
0
ファイル: OrderController.cs プロジェクト: loken73/HookedOn
        public IActionResult Checkout(Purchase order)
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;
            if (_shoppingCart.ShoppingCartItems.Count == 0)
            {
                ModelState.AddModelError("", "Your card is empty, buy some pets first");
            }

            if (ModelState.IsValid)
            {
                _orderRepository.CreateOrder(order);
                _shoppingCart.ClearCart();
                return(RedirectToAction("CheckoutComplete", new { purchaseId = order.PurchaseId }));
            }

            return(View(order));
        }