using Indotalent.Data.Entities;
using Microsoft.EntityFrameworkCore;

namespace Indotalent.Infrastructure.Database.Demo;

public static class UnitMeasureSeeder
{
    public static async Task GenerateDataAsync(AppDbContext context)
    {
        if (await context.UnitMeasure.AnyAsync()) return;

        var unitMeasures = new List<UnitMeasure>
        {
            new UnitMeasure { Name = "m" },
            new UnitMeasure { Name = "kg" },
            new UnitMeasure { Name = "hour" },
            new UnitMeasure { Name = "unit" },
            new UnitMeasure { Name = "pcs" }
        };

        foreach (var unitMeasure in unitMeasures)
        {
            await context.UnitMeasure.AddAsync(unitMeasure);
        }

        await context.SaveChangesAsync();
    }
}