public async Task <bool> SaveAll() { // Save the changes to the database if there are more than zero changes // Otherwise, don't save to the database return(await _context.SaveChangesAsync() > 0); }
public async Task <User> Register(User user, string password) { // Create byte arrays for password hash and salt byte[] passwordHash, passwordSalt; // Pass a reference for hash and salt so they can be updated CreatePasswordHash(password, out passwordHash, out passwordSalt); // Set password hash and salt for user user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; // Add user and save user information to database await _context.Users.AddAsync(user); await _context.SaveChangesAsync(); return(user); }