public ActionResult SignUpRegistration(CustomerRegistration registration) { bool customerAlreadyExists = CheckIfCustomerEmailAlreadyExists(registration.EmailAddress); bool customerLogonAlreadyExists = CheckIfUserExistsInSimpleMemberProvider(registration.EmailAddress); try { //customerLogonAlreadyExists = //create customer if that email's not in use: if (!customerAlreadyExists && !customerLogonAlreadyExists) { Customer theCustomer = Customer.MapCustomerRegistrationToNewCustomer(registration); FinalBookingDetailGatheringController customerController = new FinalBookingDetailGatheringController(); var CustomerAdded = customerController.CreateCustomerAsPartOfSignUp(theCustomer); string UserName = theCustomer.EmailAddress; string Password = registration.Password; //create the ASP.NET account WebSecurity.CreateUserAndAccount(UserName, Password); //make user a 'normal user' if (!Roles.GetRolesForUser(UserName).Contains("User")) { Roles.AddUsersToRole(new[] { UserName }, "User"); } //login and get newly created user WebSecurity.Login(UserName, Password); Session["prc_customer"] = theCustomer; return(View("SignUpSuccessful")); //log in with the new details } else { return(View("AlreadyExists")); } } catch (Exception ex) { throw new Exception("Something went wrong when trying to create a new user"); } }
public ActionResult SignUpRegistration(CustomerRegistration registration) { bool customerAlreadyExists = CheckIfCustomerEmailAlreadyExists(registration.EmailAddress); bool customerLogonAlreadyExists = CheckIfUserExistsInSimpleMemberProvider(registration.EmailAddress); try { //customerLogonAlreadyExists = //create customer if that email's not in use: if (!customerAlreadyExists && !customerLogonAlreadyExists) { Customer theCustomer = Customer.MapCustomerRegistrationToNewCustomer(registration); FinalBookingDetailGatheringController customerController = new FinalBookingDetailGatheringController(); var CustomerAdded = customerController.CreateCustomerAsPartOfSignUp(theCustomer); string UserName = theCustomer.EmailAddress; string Password = registration.Password; //create the ASP.NET account WebSecurity.CreateUserAndAccount(UserName, Password); //make user a 'normal user' if (!Roles.GetRolesForUser(UserName).Contains("User")) Roles.AddUsersToRole(new[] { UserName }, "User"); //login and get newly created user WebSecurity.Login(UserName, Password); Session["prc_customer"] = theCustomer; return View("SignUpSuccessful"); //log in with the new details } else { return View("AlreadyExists"); } } catch (Exception ex) { throw new Exception("Something went wrong when trying to create a new user"); } }