Merge pull request 'feat: ajout des options de démarrage pour l’environnement de développement dans les paramètres de lancement' (#172) from j3/refactor/arg-builder into dev
Reviewed-on: https://10.4.0.131/gitea/DI1-P4-E1/Webzine/pulls/172 Reviewed-by: Loic Masi <loic.masi@diiage.org>
This commit is contained in:
@@ -38,6 +38,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.
|
// 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 repositoryType = builder.Configuration.GetValue<RepositoryType>("Repository");
|
||||||
var seederType = builder.Configuration.GetValue<SeederType>("Seeder");
|
var seederType = builder.Configuration.GetValue<SeederType>("Seeder");
|
||||||
|
var shouldSeed = args.Contains("--seed");
|
||||||
if (repositoryType == RepositoryType.Db)
|
if (repositoryType == RepositoryType.Db)
|
||||||
{
|
{
|
||||||
if (builder.Environment.IsProduction())
|
if (builder.Environment.IsProduction())
|
||||||
@@ -77,10 +78,21 @@ try
|
|||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var db = scope.ServiceProvider.GetRequiredService<WebzineDbContext>();
|
var db = scope.ServiceProvider.GetRequiredService<WebzineDbContext>();
|
||||||
db.Database.EnsureDeleted();
|
if (shouldSeed)
|
||||||
db.Database.EnsureCreated();
|
{
|
||||||
var repo = scope.ServiceProvider.GetRequiredService<DbEntityRepository>();
|
db.Database.EnsureDeleted();
|
||||||
repo.SeedBaseDeDonnees();
|
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
|
else
|
||||||
|
|||||||
@@ -18,6 +18,26 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"http-seed": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "http://localhost:5038",
|
||||||
|
"commandLineArgs": "--seed",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https-seed": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7095;http://localhost:5038",
|
||||||
|
"commandLineArgs": "--seed",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user