public static void SeedUsers(ZaiZaiDateDbContext dbContext) { if (dbContext is null) { throw new ArgumentNullException(nameof(dbContext)); } if (dbContext.Users.Any()) { return; } var userData = ReadUsersFile(); var users = JsonConvert.DeserializeObject <List <AppUser> >(userData); foreach (var user in users) { byte[] passwordHash, passwordSalt; CreatePasswordHash("pwd12345", out passwordHash, out passwordSalt); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; user.UserName = user.UserName.ToLowerInvariant(); user.CreatedDate = DateTimeOffset.UtcNow; dbContext.Users.Add(user); } dbContext.SaveChanges(); }
public AuthenticationService(ZaiZaiDateDbContext dbContext) { _dbContext = dbContext; }
public UserManagementService(ZaiZaiDateDbContext dbContext) { _dbContext = dbContext; }