Ejemplo n.º 1
0
        public ActionResult DeliveryMethod(CheckoutDeliveryMethodShippingViewModel 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 (config.CheckoutDeliveryMethodWebForm != null)
            {
                FormProcessorExtensions.ValidateFields(this, config.CheckoutDeliveryMethodWebForm);
            }

            if (ModelState.IsValid)
            {
                WebFormResponse webFormResponse = cart.DeliveryMethodProcessWebForm(this);
                if (webFormResponse != null)
                {
                    cart.DeliveryInfoShipping.DeliveryMethodWebFormResponseId = webFormResponse.WebFormResponseId;
                }
                cart.DeliveryInfoShipping.ShippingDeliveryMethod = viewModel.ShippingDeliveryMethod;
                cart.DeliveryInfoShipping.ShippingDeliveryMethod = viewModel.ShippingDeliveryMethod;
                cart.StatusSelectedDeliveryMethod = true;
                GStoreDb.Carts.Update(cart);
                GStoreDb.SaveChanges();

                GStoreDb.LogUserActionEvent(HttpContext, RouteData, this, UserActionCategoryEnum.Checkout, UserActionActionEnum.Checkout_SelectedDeliveryMethod, "", true, cartId: cart.CartId);

                return(RedirectToAction("PaymentInfo"));
            }
            viewModel.UpdateForRepost(config, cart, RouteData.Action());
            return(View("DeliveryMethod", viewModel));
        }
Ejemplo n.º 2
0
        public ActionResult DeliveryMethod()
        {
            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.AllItemsAreDigitalDownload)
            {
                if (!cart.StatusSelectedDeliveryMethod)
                {
                    cart.StatusSelectedDeliveryMethod = true;
                    GStoreDb.Carts.Update(cart);
                    GStoreDb.SaveChanges();

                    GStoreDb.LogUserActionEvent(HttpContext, RouteData, this, UserActionCategoryEnum.Checkout, UserActionActionEnum.Checkout_SelectedDeliveryMethod, "All Digital", true, cartId: cart.CartId);
                }
                return(RedirectToAction("PaymentInfo"));
            }

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

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