public async Task <User> RegisterAsync(User user, string password) { if (string.IsNullOrWhiteSpace(password)) { throw new ArgumentNullException("Password is required"); } byte[] passwordHash; byte[] passwordSalt; CreatePasswordHashAndPasswordSalt(password, out passwordHash, out passwordSalt); user.UpdatePasswordHashAndSalt(passwordHash, passwordSalt); _context.Users.Add(user); await _context.SaveChangesAsync(); return(user); }
public async Task AddBlogAsync(Blog blog) { await _context.Blogs.AddAsync(blog); await _context.SaveChangesAsync(); }