namespace Diligent.WebAPI.Host.Extensions;
[ExcludeFromCodeCoverage]
public static class DataConfigurationExtension
{
///
/// Services configuration
///
public static async void ConfigureData(this WebApplicationBuilder builder)
{
IServiceCollection services = builder.Services;
services.ConfigureData(builder.Configuration);
}
///
/// App configuration
///
public async static void ConfigureData(this WebApplication app)
{
using (var serviceScope = app.Services.CreateScope())
{
var roleManager = serviceScope.ServiceProvider.GetRequiredService>();
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);
}
}