public static UserEntity CreateActiveUser(string email, Role role) { using (var context = new DatabaseContext()) { var passwordManager = new PasswordManager(new Configuration()); var salt = passwordManager.GenerateSalt(); var hashedPassword = passwordManager.HashPassword(Password, salt); var enctyptedSecurePhrase = passwordManager.EncryptSecurePhrase(Phrase); var user = new UserEntity { Id = Guid.NewGuid(), Email = email, FirstName = email, LastName = email, Role = role, UserState = UserState.Activated, PasswordSalt = salt, HashedPassword = hashedPassword, EncryptedSecurePhrase = enctyptedSecurePhrase, FirstSecurePhraseQuestionCharacterIndex = 0, SecondSecurePhraseQuestionCharacterIndex = 1, }; context.Users.Add(user); context.SaveChanges(); return user; } }
public void CreateUser(UserData user) { using (var context = new DatabaseContext()) { var entity = new UserEntity(user); context.Users.Add(entity); context.SaveChanges(); } }