diff --git a/Controllers/Seed.cs b/Controllers/Seed.cs index 76e6250..e9fc2f8 100644 --- a/Controllers/Seed.cs +++ b/Controllers/Seed.cs @@ -21,6 +21,7 @@ namespace QuotifyBE.Controllers } public async Task SeedAsync() { + // Create a user account if no exist var AccountNum = await _db.Users.CountAsync(); if (AccountNum == 0) { @@ -34,8 +35,24 @@ namespace QuotifyBE.Controllers }; _db.Users.Add(Admin); await _db.SaveChangesAsync(); + Console.WriteLine("[QuotifyBE] Administrator user account added!\nDefault credentials are: admin@mail.com, password: admin"); } - + + // Create sitewide statistic - number of draws + Statistic? numOfDraws = await _db.Statistics + .FirstOrDefaultAsync(s => s.Label == "number_of_draws"); + if (numOfDraws == null) + { + Statistic newRow = new Statistic + { + Label = "number_of_draws", + IValue = 0 + }; + _db.Statistics.Add(newRow); + await _db.SaveChangesAsync(); + Console.WriteLine("[QuotifyBE] Sitewide statistic for number of draws added!"); + } + } } }