public static async Task SeedUser(dataContext context) { if (await context.Users.AnyAsync()) { return; } var userData = await System.IO.File.ReadAllTextAsync("data/UserSeedData.json"); //var users = JsonConvert.DeserializeObject<List<appUser>>(userData); var users = JsonSerializer.Deserialize <List <appUser> >(userData); foreach (var user in users) { using var hmac = new HMACSHA512(); user.UserName = user.UserName.ToLower(); user.passwordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes("Password")); user.PasswordSalt = hmac.Key; context.Users.Add(user); } await context.SaveChangesAsync(); }
public userRepository(dataContext context, IMapper mapper) { _mapper = mapper; _context = context; }