Пример #1
0
        public IViewComponentResult Invoke()
        {
            var items = _dealerCart.GetDealerCartItems();

            _dealerCart.DealerCartItems = items;

            var model = new DealerCartVM
            {
                DealerCart = _dealerCart,
                CartTotal  = _dealerCart.GetCartTotal()
            };

            return(View(model));
        }
Пример #2
0
        public IActionResult Index()
        {
            var items = _dealerCart.GetDealerCartItems();

            _dealerCart.DealerCartItems = items;

            var model = new DealerCartVM
            {
                DealerCart = _dealerCart,
                CartTotal  = _dealerCart.GetCartTotal()
            };

            return(View(model));
        }
Пример #3
0
        public IActionResult CheckOut(Order order)
        {
            var items = _dealerCart.GetDealerCartItems();

            _dealerCart.DealerCartItems = items;

            int itemsInCartCounter = _dealerCart.DealerCartItems.Count();

            if (itemsInCartCounter == 0)
            {
                ModelState.AddModelError("", "Your order is empty");
            }

            if (ModelState.IsValid)
            {
                _orderRepository.CreateOrder(order);
                _dealerCart.ClearCart();
                return(RedirectToAction(nameof(OrderFullfilled)));
            }

            return(View(order));
        }