Esempio n. 1
0
        public static async Task SeedUsers(userdata data)
        {
            if (await data.users.AnyAsync())
            {
                return;
            }
            var seed = await System.IO.File.ReadAllTextAsync("Data/UserSeedData.json");

            var users = JsonSerializer.Deserialize <List <Appusers> >(seed);

            foreach (var user in users)
            {
                using var hmac = new HMACSHA512();

                user.PasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes("password"));
                user.PasswordSalt = hmac.Key;
                data.users.Add(user);
            }

            await data.SaveChangesAsync();
        }
Esempio n. 2
0
 public async Task <bool> SaveAllAsync()
 {
     return(await _data.SaveChangesAsync() > 0);
 }