feat: ensure the number of draws is present in the db

This commit is contained in:
2025-07-21 11:16:46 +02:00
parent db6f57830a
commit 05e6b9bc86

View File

@@ -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,6 +35,22 @@ 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!");
}
}