/// <summary> /// Create a new UserAuth record. /// </summary> /// <param name="newUser">The new user.</param> /// <param name="password">The password.</param> /// <returns>The <see cref="IUserAuth"/>.</returns> public IUserAuth CreateUserAuth(IUserAuth newUser, string password) { this.ValidateNewUser(newUser, password); this.AssertNoExistingUser(newUser); string salt; string hash; this.passwordHasher.GetHashAndSaltString(password, out hash, out salt); newUser.PasswordHash = hash; newUser.Salt = salt; newUser.CreatedDate = DateTime.UtcNow; newUser.ModifiedDate = newUser.CreatedDate; var record = new UserAuth(); record.PopulateWith(newUser); this.unitOfWork.Add(record); this.unitOfWork.SaveChanges(); return record; }