public void SetUp() { _context.Products.RemoveRange(_context.Products); _context.Comments.RemoveRange(_context.Comments); _context.Users.RemoveRange(_context.Users); _context.SaveChanges(); }
public User Create(User user, string password) { if (string.IsNullOrWhiteSpace(password)) { throw new AppException("Password is required"); } if (_context.Users.Any(x => x.Username == user.Username)) { throw new AppException($"Username {user.Username} is already taken"); } byte[] passwordHash, passwordSalt; CreatePasswordHash(password, out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; _context.Users.Add(user); _context.SaveChanges(); return(user); }
public void SetUp() { _context.Users.RemoveRange(_context.Users); _context.SaveChanges(); }
public bool Save() { return(_context.SaveChanges() >= 0); }