using Aberwyn.Models;
using Microsoft.EntityFrameworkCore;

namespace Aberwyn.Data
{
    public static class TestDataSeeder
    {
        public static async Task SeedBudget(ApplicationDbContext context)
        {
            if (await context.BudgetPeriods.AnyAsync()) return;

            var period = new BudgetPeriod
            {
                Year = DateTime.Now.Year,
                Month = DateTime.Now.Month,
                Categories = new List<BudgetCategory>
                {
                    new BudgetCategory
                    {
                        Name = "Inkomster",
                        Color = "#2d6a4f",
                        Items = new List<BudgetItem>
                        {
                            new BudgetItem { Name = "Elias lön", Amount = 27000, IsExpense = false },
                            new BudgetItem { Name = "Elin lön", Amount = 24000, IsExpense = false },
                        }
                    },
                    new BudgetCategory
                    {
                        Name = "Fasta utgifter",
                        Color = "#c1121f",
                        Items = new List<BudgetItem>
                        {
                            new BudgetItem { Name = "Hyra", Amount = 8900, IsExpense = true },
                            new BudgetItem { Name = "El", Amount = 1200, IsExpense = true },
                            new BudgetItem { Name = "Internet", Amount = 400, IsExpense = true },
                        }
                    },
                    new BudgetCategory
                    {
                        Name = "Sparande",
                        Color = "#6a4c93",
                        Items = new List<BudgetItem>
                        {
                            new BudgetItem { Name = "Buffert", Amount = 3000, IsExpense = false, IncludeInSummary = false },
                        }
                    }
                }
            };

            context.BudgetPeriods.Add(period);
            await context.SaveChangesAsync();
        }
    }
}
