//IContactable Wrappers /* public string ContactFirstName { get; set; } public string ContactLastName { get; set; } public string ContactEmailAddress { get; set; }*/ ///////////////////// //static methods ///////////////////// /// public static Customer MapCustomerRegistrationToNewCustomer(CustomerRegistration theCustomerRegistration) { try { Customer theCustomer = new Customer { Title = theCustomerRegistration.Title, Address1 = theCustomerRegistration.Address1, Address2 = theCustomerRegistration.Address2, AltEmailAddress = theCustomerRegistration.AltEmailAddress, AltTelephone = theCustomerRegistration.AltTelephone, CompanyTelephone = theCustomerRegistration.CompanyTelephone, County = theCustomerRegistration.County, Country = theCustomerRegistration.Country, CreationDate = theCustomerRegistration.CreationDate, DOB = theCustomerRegistration.DOB, DayTimeTelephone = theCustomerRegistration.DayTimeTelephone, HomeTelephone = theCustomerRegistration.HomeTelephone, EmailAddress = theCustomerRegistration.EmailAddress, FirstName = theCustomerRegistration.FirstName, LastName = theCustomerRegistration.LastName, MiddleName = theCustomerRegistration.MiddleName, Town = theCustomerRegistration.Town, Postcode = theCustomerRegistration.Postcode, MobileTelephone = theCustomerRegistration.MobileTelephone, PreferredCurrency = theCustomerRegistration.PreferredCurrency, PreferredCurrencySymbol = theCustomerRegistration.PreferredCurrencySymbol, Test = theCustomerRegistration.Test }; return theCustomer; } catch (Exception ex) { throw ex; } }
//IContactable Wrappers /* public string ContactFirstName { get; set; } * public string ContactLastName { get; set; } * public string ContactEmailAddress { get; set; }*/ ///////////////////// //static methods ///////////////////// /// public static Customer MapCustomerRegistrationToNewCustomer(CustomerRegistration theCustomerRegistration) { try { Customer theCustomer = new Customer { Title = theCustomerRegistration.Title, Address1 = theCustomerRegistration.Address1, Address2 = theCustomerRegistration.Address2, AltEmailAddress = theCustomerRegistration.AltEmailAddress, AltTelephone = theCustomerRegistration.AltTelephone, CompanyTelephone = theCustomerRegistration.CompanyTelephone, County = theCustomerRegistration.County, Country = theCustomerRegistration.Country, CreationDate = theCustomerRegistration.CreationDate, DOB = theCustomerRegistration.DOB, DayTimeTelephone = theCustomerRegistration.DayTimeTelephone, HomeTelephone = theCustomerRegistration.HomeTelephone, EmailAddress = theCustomerRegistration.EmailAddress, FirstName = theCustomerRegistration.FirstName, LastName = theCustomerRegistration.LastName, MiddleName = theCustomerRegistration.MiddleName, Town = theCustomerRegistration.Town, Postcode = theCustomerRegistration.Postcode, MobileTelephone = theCustomerRegistration.MobileTelephone, PreferredCurrency = theCustomerRegistration.PreferredCurrency, PreferredCurrencySymbol = theCustomerRegistration.PreferredCurrencySymbol, Test = theCustomerRegistration.Test }; return(theCustomer); } catch (Exception ex) { throw ex; } }
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"); } }