public ActionResult Register(RegisterViewModel model) { string returnUrl = string.Empty; if (ModelState.IsValid) { if (_workContext.CurrentCustomer.IsRegistered()) { //Already registered customer. _authenticationService.SignOut(); //Save a new record _workContext.CurrentCustomer = _customerService.InsertGuestCustomer(); } var customer = _workContext.CurrentCustomer; customer.FirstName = model.FirstName; customer.LastName = model.LastName; bool isApproved = true; var registrationRequest = new CustomerRegistrationRequest(customer, model.Email, model.Password,isApproved); var registrationResult = _customerService.RegisterCustomer(registrationRequest); if (registrationResult.Success) { //login customer now if (isApproved) _authenticationService.SignIn(customer, true); //form fields //notifications //if (_customerSettings.NotifyNewCustomerRegistration) // _workflowMessageService.SendCustomerRegisteredNotificationMessage(customer, _localizationSettings.DefaultAdminLanguageId); switch (UserRegistrationType.Standard) { case UserRegistrationType.Standard: { ////send customer welcome message //_workflowMessageService.SendCustomerWelcomeMessage(customer, _workContext.WorkingLanguage.Id); //var redirectUrl = Url.RouteUrl("RegisterResult", new { resultId = (int)UserRegistrationType.Standard }); //if (!String.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl)) // redirectUrl = _webHelper.ModifyQueryString(redirectUrl, "returnurl=" + HttpUtility.UrlEncode(returnUrl), null); //return Redirect(redirectUrl); //send email _workflowMessageService.SendCustomerWelcomeMessage(customer); GutterCleanRequestModel Requestmodel = _httpContext.Session["GutterCleanRequestModel"] as GutterCleanRequestModel; if (Requestmodel == null) { return RedirectToRoute("GutterCleanRequest"); } else { return RedirectToRoute("ProcessPayment"); } } default: { return RedirectToRoute("GutterCleanRequest"); } } } //errors foreach (var error in registrationResult.Errors) ModelState.AddModelError("", error); } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult Register() { //GutterCleanRequestModel model = _httpContext.Session["GutterCleanRequestModel"] as GutterCleanRequestModel; //if (model == null) //{ // return RedirectToRoute("GutterCleanRequest"); //} RegisterViewModel modelRegister = new RegisterViewModel(); return View(modelRegister); }