コード例 #1
0
        public ActionResult ConfirmOrder(CheckoutConfirmOrderViewModel viewModel)
        {
            StoreFrontConfiguration config = CurrentStoreFrontConfigOrThrow;
            Cart cart = config.StoreFront.GetCart(Session.SessionID, CurrentUserProfileOrNull);

            if (!cart.CartIsValidForCheckout(this))
            {
                return(RedirectToAction("Index", "Cart"));
            }

            if (!cart.StatusStartedCheckout)
            {
                return(RedirectToAction("Index"));
            }
            if (!cart.StatusSelectedLogInOrGuest)
            {
                return(RedirectToAction("LogInOrGuest"));
            }

            cart = cart.ValidateCartAndSave(this);

            if (!cart.StatusCompletedDeliveryInfo)
            {
                return(RedirectToAction("DeliveryInfo"));
            }
            if (!cart.StatusSelectedDeliveryMethod)
            {
                return(RedirectToAction("DeliveryMethod"));
            }
            if (!cart.StatusPaymentInfoConfirmed)
            {
                return(RedirectToAction("PaymentInfo"));
            }

            if (config.CheckoutConfirmOrderWebForm != null)
            {
                FormProcessorExtensions.ValidateFields(this, config.CheckoutConfirmOrderWebForm);
            }

            if (ModelState.IsValid)
            {
                WebFormResponse webFormResponse = cart.ConfirmOrderProcessWebForm(this);
                if (webFormResponse != null)
                {
                    cart.ConfirmOrderWebFormResponseId = webFormResponse.WebFormResponseId;
                    GStoreDb.Carts.Update(cart);
                    GStoreDb.SaveChanges();
                }

                return(cart.ProcessOrderAndPayment(this));
            }

            viewModel.UpdateForRepost(config, cart, RouteData.Action());
            return(View("ConfirmOrder", viewModel));
        }
コード例 #2
0
        public ActionResult ConfirmOrder()
        {
            StoreFrontConfiguration config = CurrentStoreFrontConfigOrThrow;
            Cart cart = config.StoreFront.GetCart(Session.SessionID, CurrentUserProfileOrNull);

            if (!cart.CartIsValidForCheckout(this))
            {
                return(RedirectToAction("Index", "Cart"));
            }

            if (!cart.StatusStartedCheckout)
            {
                return(RedirectToAction("Index"));
            }
            if (!cart.StatusSelectedLogInOrGuest)
            {
                return(RedirectToAction("LogInOrGuest"));
            }

            cart = cart.ValidateCartAndSave(this);

            if (!cart.StatusCompletedDeliveryInfo)
            {
                return(RedirectToAction("DeliveryInfo"));
            }
            if (!cart.StatusSelectedDeliveryMethod)
            {
                return(RedirectToAction("DeliveryMethod"));
            }
            if (!cart.StatusPaymentInfoConfirmed)
            {
                return(RedirectToAction("PaymentInfo"));
            }

            CheckoutConfirmOrderViewModel viewModel = new CheckoutConfirmOrderViewModel(config, cart, RouteData.Action());

            return(View("ConfirmOrder", viewModel));
        }