Esempio n. 1
0
        public static async Task SeedUsers(DatingDataContext datacontext)
        {
            if (await datacontext.AppUsers.AnyAsync())
            {
                return;
            }

            var userData = await System.IO.File.ReadAllTextAsync("Data/UserSeedData.json");

            var users = JsonSerializer.Deserialize <List <AppUser> >(userData);

            users.ForEach(userData => {
                using var hmac        = new HMACSHA512();
                userData.UserName     = userData.UserName.ToLower();
                userData.PasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes("Password"));
                userData.PasswordSalt = hmac.Key;

                datacontext.AppUsers.Add(userData);
            });

            await datacontext.SaveChangesAsync();
        }
Esempio n. 2
0
 public UserRepository(DatingDataContext context, IMapper mapper)
 {
     this._context = context;
     this._mapper  = mapper;
 }