using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using PnvPanel.Application.Common.Interfaces; using PnvPanel.Domain.Plans; using PnvPanel.Infrastructure.Persistence; namespace PnvPanel.Infrastructure.Plans; internal sealed class PlanSeeder(AppDbContext dbContext, ILogger logger) : IPlanSeeder { public async Task SeedIfEmptyAsync(CancellationToken cancellationToken) { if (await dbContext.Plans.AnyAsync(cancellationToken)) return; dbContext.Plans.AddRange( Plan.Create("Стандарт", 3, 0), Plan.Create("Плюс", 6, 1), Plan.Create("Про", 9, 2) ); await dbContext.SaveChangesAsync(cancellationToken); logger.LogInformation("Seeded default plans"); } }