using Microsoft.Extensions.DependencyInjection;
using TeleWave.Infrastructure.Library;

namespace TeleWave.Infrastructure.Identity;

public static class DbInitializerExtensions
{
    public static async Task SeedDataAsync(
        this IServiceProvider services,
        CancellationToken cancellationToken = default
    )
    {
        await using var scope = services.CreateAsyncScope();

        var initializer = scope.ServiceProvider.GetRequiredService<DbInitializer>();
        await initializer.SeedAsync(cancellationToken);

        var genreSeeder = scope.ServiceProvider.GetRequiredService<GenreSeeder>();
        await genreSeeder.SeedAsync(cancellationToken);
    }
}
