Merge branch 'dev' into j3/feat/business-logic/titre-admin
# Conflicts: # Webzine.Business/Webzine.Business.csproj # Webzine.WebApplication/Program.cs
This commit is contained in:
@@ -40,6 +40,7 @@ try
|
||||
// En fonction de la configuration, utilise soit les repositories basés sur une base de données, soit les repositories basés sur des listes locales.
|
||||
var repositoryType = builder.Configuration.GetValue<RepositoryType>("Repository");
|
||||
var seederType = builder.Configuration.GetValue<SeederType>("Seeder");
|
||||
var shouldSeed = args.Contains("--seed");
|
||||
if (repositoryType == RepositoryType.Db)
|
||||
{
|
||||
if (builder.Environment.IsProduction())
|
||||
@@ -68,6 +69,7 @@ try
|
||||
builder.Services.AddSingleton<InMemoryDataStore>();
|
||||
}
|
||||
|
||||
builder.Services.AddScoped<IDashboardService, DashboardService>();
|
||||
builder.Services.AddScoped<ITitreAdminService, TitreAdminService>();
|
||||
|
||||
// https://learn.microsoft.com/fr-fr/aspnet/core/performance/response-compression?view=aspnetcore-10.0#configuration
|
||||
@@ -81,10 +83,23 @@ try
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var db = scope.ServiceProvider.GetRequiredService<WebzineDbContext>();
|
||||
db.Database.EnsureDeleted();
|
||||
db.Database.EnsureCreated();
|
||||
var repo = scope.ServiceProvider.GetRequiredService<DbEntityRepository>();
|
||||
repo.SeedBaseDeDonnees();
|
||||
|
||||
if (shouldSeed)
|
||||
{
|
||||
db.Database.EnsureDeleted();
|
||||
db.Database.EnsureCreated();
|
||||
var repo = scope.ServiceProvider.GetRequiredService<DbEntityRepository>();
|
||||
|
||||
if (seederType == SeederType.Local)
|
||||
{
|
||||
repo.SeedBaseDeDonnees();
|
||||
}
|
||||
else if (seederType == SeederType.Spotify)
|
||||
{
|
||||
// Seed à l'aide de l'API Spotify.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user