Exemplo n.º 1
0
        public IActionResult Checkout(OrderFormHolder holder)
        {
            var validationResult = orderFormValidator.ValidateOnCheckout(holder.Form, ModelState);

            if (validationResult.ModelStateViewModel.IsValid)
            {
                orderFormHandler.HandleCheckout(holder.Form, validationResult);
                return(RedirectToAction("Complete"));
            }

            return(View("Checkout", orderModelBuilder.BuildByForm(holder.Form)));
        }
Exemplo n.º 2
0
        public IActionResult Checkout(OrderFormHolder holder)
        {
            autoShopCart.ListAutoShopItems = autoShopCart.GetAutoShopItems();

            if (autoShopCart.ListAutoShopItems.Count == 0)
            {
                ModelState.AddModelError("EmptyCart", "Корзина не должна быть пустой!");
            }

            var validationResult = orderFormValidator.ValidateOnCheckout(holder.Form, ModelState);

            if (validationResult.ModelStateViewModel.IsValid)
            {
                orderFormHandler.HandleCheckout(holder.Form, validationResult);
                return(RedirectToAction("Complete"));
            }

            return(View(holder.Form));
        }