/// <summary> /// Create an account from the view. /// </summary> /// <param name="createAccountViewModel"> The create account view model. </param> /// <param name="linkToHome"> The link To Home. </param> /// <returns> The <see cref="CreateAccountViewModel"/>. </returns> public CreateAccountViewModel CreateAccount(CreateAccountViewModel createAccountViewModel, Uri linkToHome) { // Convert the given View Model to the coresponding data model var userToCreate = this.userConversions.ConvertCreateAccountViewModelToUser(createAccountViewModel); // Set up the credentials with a hashed password. userToCreate.UserCredential = new UserCredential { UserName = createAccountViewModel.UserName, PasswordHash = PasswordHash.HashPassword(PasswordHash.CreateSalt(createAccountViewModel.UserName.ToLower()), createAccountViewModel.Password) }; userToCreate.IsActive = true; userToCreate.Contact = new Contact(); // Create the user in the database. var createdUser = this.userRepo.CreateUser(userToCreate); var userView = this.userConversions.ConvertUserToCreateAccountViewModel(createdUser); if (userView != null) { var email = new AccountCreatedEmail(userView.UserName, userView.UserType); email.Send(linkToHome); } // Return the corresponding view model return(userView); }
public void ProviderSendTest() { using (ShimsContext.Create()) { var email = new AccountCreatedEmail("*****@*****.**", UserRoleType.Provider); var result = email.Send(new Uri("http://localhost/Web/Index")); Assert.IsTrue(result.Contains("a Service Provider")); } }
public void AdminSendTest() { using (ShimsContext.Create()) { var email = new AccountCreatedEmail("*****@*****.**", UserRoleType.Admin); var result = email.Send(new Uri("http://localhost/Web/Index")); Assert.IsTrue(result.Contains("an Administrator")); } }