Exemplo n.º 1
0
        /// <summary>
        /// Initializes the controller context for creating controllers dynamically
        /// </summary>
        /// <param name="httpContext"></param>
        /// <param name="controller"></param>
        /// <param name="action"></param>
        /// <param name="area"></param>
        public void InitContext(System.Web.HttpContext httpContext, string controller, string action, string area, TempDataDictionary tempData)
        {
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (string.IsNullOrEmpty(controller))
            {
                throw new ArgumentNullException("controller");
            }
            if (string.IsNullOrEmpty(action))
            {
                throw new ArgumentNullException("action");
            }

            if (this.ControllerContext == null)
            {
                System.Web.Routing.RouteData routeData = new RouteData();
                routeData.Area(area ?? "");
                routeData.Controller(controller);
                routeData.Action(action);
                this.ControllerContext = new ControllerContext(new HttpContextWrapper(System.Web.HttpContext.Current), routeData, this);
                if (tempData != null)
                {
                    this.TempData = tempData;
                }
            }
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
0
        public ActionResult PaymentInfo(CheckoutPaymentInfoViewModel 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 (config.CheckoutPaymentInfoWebForm != null)
            {
                FormProcessorExtensions.ValidateFields(this, config.CheckoutPaymentInfoWebForm);
            }

            if (ModelState.IsValid)
            {
                WebFormResponse webFormResponse = cart.PaymentInfoProcessWebForm(this);
                if (config.PaymentMethod_PayPal_Enabled)
                {
                    return(Payment_PayPalStartPayment(viewModel, webFormResponse));
                }


                //payment with pay after order/no automated processing
                CartPaymentInfo cartPaymentInfo = null;
                if (cart.CartPaymentInfo == null)
                {
                    cartPaymentInfo = GStoreDb.CartPaymentInfos.Create();
                    cartPaymentInfo.SetDefaults(CurrentUserProfileOrNull);
                    cartPaymentInfo.Client           = CurrentClientOrThrow;
                    cartPaymentInfo.ClientId         = cartPaymentInfo.Client.ClientId;
                    cartPaymentInfo.StoreFront       = CurrentStoreFrontOrThrow;
                    cartPaymentInfo.StoreFrontId     = cartPaymentInfo.StoreFront.StoreFrontId;
                    cartPaymentInfo.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
                    cartPaymentInfo.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
                    cartPaymentInfo.Cart             = cart;
                    cartPaymentInfo.CartId           = cart.CartId;
                    if (webFormResponse != null)
                    {
                        cartPaymentInfo.WebFormResponseId = webFormResponse.WebFormResponseId;
                    }

                    cartPaymentInfo = GStoreDb.CartPaymentInfos.Add(cartPaymentInfo);
                }
                else
                {
                    cartPaymentInfo = cart.CartPaymentInfo;
                    if (webFormResponse != null)
                    {
                        cartPaymentInfo.WebFormResponseId = webFormResponse.WebFormResponseId;
                    }
                    cartPaymentInfo = GStoreDb.CartPaymentInfos.Update(cartPaymentInfo);
                }

                //add/remove/etc
                cart.StatusPaymentInfoConfirmed = true;
                GStoreDb.Carts.Update(cart);
                GStoreDb.SaveChanges();

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

                return(RedirectToAction("ConfirmOrder"));
            }

            viewModel.UpdateForRepost(config, cart, RouteData.Action());
            return(View("PaymentInfo", viewModel));
        }
Exemplo n.º 6
0
        public ActionResult LogInOrGuest(bool?ContinueAsGuest, bool?ContinueAsLogin)
        {
            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"));
            }

            cart = cart.ValidateCartAndSave(this);

            if (ContinueAsGuest ?? false)
            {
                if (!cart.StatusSelectedLogInOrGuest)
                {
                    cart.StatusSelectedLogInOrGuest = true;
                    GStoreDb.Carts.Update(cart);
                    GStoreDb.SaveChanges();

                    GStoreDb.LogUserActionEvent(HttpContext, RouteData, this, UserActionCategoryEnum.Checkout, UserActionActionEnum.Checkout_SelectedLogInOrGuest, "", true, cartId: cart.CartId);
                    return(RedirectToAction("DeliveryInfo"));
                }
            }

            UserProfile profile = CurrentUserProfileOrNull;

            if ((ContinueAsLogin ?? false) && (profile != null))
            {
                cart.StatusSelectedLogInOrGuest = true;
                GStoreDb.Carts.Update(cart);
                GStoreDb.SaveChanges();

                GStoreDb.LogUserActionEvent(HttpContext, RouteData, this, UserActionCategoryEnum.Checkout, UserActionActionEnum.Checkout_SelectedLogInOrGuest, "", true, cartId: cart.CartId);
                return(RedirectToAction("DeliveryInfo"));
            }

            if (profile != null)
            {
                cart.StatusSelectedLogInOrGuest = true;
                GStoreDb.Carts.Update(cart);
                GStoreDb.SaveChanges();

                return(RedirectToAction("DeliveryInfo"));
            }

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

            return(View("LogInOrGuest", viewModel));
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
0
        public ActionResult DeliveryInfoShipping(CheckoutDeliveryInfoShippingViewModel 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.AllItemsAreDigitalDownload)
            {
                return(RedirectToAction("DeliveryInfo"));
            }

            //check if custom form is valid
            if (config.CheckoutDeliveryInfoShippingWebForm != null)
            {
                FormProcessorExtensions.ValidateFields(this, config.CheckoutDeliveryInfoShippingWebForm);
            }

            if (ModelState.IsValid)
            {
                WebFormResponse webFormResponse = cart.DeliveryInfoShippingProcessWebForm(this);

                DeliveryInfoShipping info = null;
                if (cart.DeliveryInfoShipping == null)
                {
                    info = GStoreDb.DeliveryInfoShippings.Create();
                    info.SetDefaults(CurrentUserProfileOrNull);
                    info.Client           = CurrentClientOrThrow;
                    info.ClientId         = info.Client.ClientId;
                    info.StoreFront       = CurrentStoreFrontOrThrow;
                    info.StoreFrontId     = info.StoreFront.StoreFrontId;
                    info.StartDateTimeUtc = DateTime.UtcNow.AddMinutes(-1);
                    info.EndDateTimeUtc   = DateTime.UtcNow.AddYears(100);
                    info.Cart             = cart;
                    info.CartId           = cart.CartId;

                    info.AdddressL1   = viewModel.AdddressL1;
                    info.AdddressL2   = viewModel.AdddressL2;
                    info.EmailAddress = viewModel.EmailAddress;
                    info.FullName     = viewModel.FullName;
                    info.City         = viewModel.City;
                    info.State        = viewModel.State;
                    info.PostalCode   = viewModel.PostalCode;
                    info.CountryCode  = viewModel.CountryCode.Value;
                    if (webFormResponse != null)
                    {
                        info.WebFormResponseId = webFormResponse.WebFormResponseId;
                    }
                    info = GStoreDb.DeliveryInfoShippings.Add(info);
                }
                else
                {
                    info              = cart.DeliveryInfoShipping;
                    info.AdddressL1   = viewModel.AdddressL1;
                    info.AdddressL2   = viewModel.AdddressL2;
                    info.EmailAddress = viewModel.EmailAddress;
                    info.FullName     = viewModel.FullName;
                    info.City         = viewModel.City;
                    info.State        = viewModel.State;
                    info.PostalCode   = viewModel.PostalCode;
                    info.CountryCode  = viewModel.CountryCode.Value;
                    if (webFormResponse != null)
                    {
                        info.WebFormResponseId = webFormResponse.WebFormResponseId;
                    }
                    info = GStoreDb.DeliveryInfoShippings.Update(info);
                }

                cart.DeliveryInfoShipping = info;
                cart.Email    = viewModel.EmailAddress;
                cart.FullName = viewModel.FullName;
                cart.StatusCompletedDeliveryInfo = true;
                GStoreDb.Carts.Update(cart);
                GStoreDb.SaveChanges();

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

                return(RedirectToAction("DeliveryMethod"));
            }

            viewModel.UpdateForRepost(config, cart, RouteData.Action());
            return(View("DeliveryInfoShipping", viewModel));
        }
Exemplo n.º 9
0
        public ActionResult DeliveryInfo()
        {
            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.AllItemsAreDigitalDownload)
            {
                CheckoutDeliveryInfoDigitalOnlyViewModel viewModelDigitalOnly = new CheckoutDeliveryInfoDigitalOnlyViewModel(config, cart, RouteData.Action());
                return(View("DeliveryInfoDigitalOnly", viewModelDigitalOnly));
            }
            else
            {
                CheckoutDeliveryInfoShippingViewModel viewModelShipping = new CheckoutDeliveryInfoShippingViewModel(config, cart, RouteData.Action());
                return(View("DeliveryInfoShipping", viewModelShipping));
            }
        }