| 123456789101112131415161718192021222324252627282930313233343536373839 |
- namespace Diligent.WebAPI.Host.Extensions;
-
- [ExcludeFromCodeCoverage]
- public static class DataConfigurationExtension
- {
- /// <summary>
- /// Services configuration
- /// </summary>
- public static async void ConfigureData(this WebApplicationBuilder builder)
- {
- IServiceCollection services = builder.Services;
- services.ConfigureData(builder.Configuration);
- }
-
- /// <summary>
- /// App configuration
- /// </summary>
- public async static void ConfigureData(this WebApplication app)
- {
-
- using (var serviceScope = app.Services.CreateScope())
- {
- var roleManager = serviceScope.ServiceProvider.GetRequiredService<RoleManager<AppRole>>();
- if (!await roleManager.RoleExistsAsync("SuperAdmin"))
- {
- var managerRole = new AppRole("SuperAdmin");
- await roleManager.CreateAsync(managerRole);
- }
- if (!await roleManager.RoleExistsAsync("Admin"))
- {
- var managerRole = new AppRole("Admin");
- await roleManager.CreateAsync(managerRole);
- }
- }
-
- DataSeeder.SeedUser(app.Services);
- DataSeeder.SeedTags(app.Services);
- }
- }
|