public ActionResult LogInOrGuest(CheckoutLogInOrGuestViewModel 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"); } cart = cart.ValidateCartAndSave(this); if (config.CheckoutLogInOrGuestWebForm != null) { FormProcessorExtensions.ValidateFields(this, config.CheckoutLogInOrGuestWebForm); } if (ModelState.IsValid) { WebFormResponse webFormResponse = cart.LoginOrGuestProcessWebForm(this); if (webFormResponse != null) { cart.LoginOrGuestWebFormResponseId = webFormResponse.WebFormResponseId; } 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"); } viewModel.UpdateForRepost(config, cart, RouteData.Action()); return View("LogInOrGuest", viewModel); }
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); }