private void Save_Click(object sender, EventArgs e) { NewUser = new NewUser { Password = tbxPassword.Text, UserName = tbxUserName.Text }; }
public User CreateNew(NewUser model) { using (var contextAccessor = new WriteContextAccessor()) { SHA256Managed sha = new SHA256Managed(); sha.Initialize(); var user = new User { Name = model.UserName, PasswordHash = sha.ComputeHash(Encoding.UTF8.GetBytes(model.Password)).ToHexString() }; contextAccessor.ReadWriteContext.Users.Add(user); contextAccessor.ReadWriteContext.SaveChanges(); return user; } }