using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace Aberwyn.Models
{

    public class WeeklyMenuViewModel
    {
        public int WeekNumber { get; set; }
        public int Year { get; set; }

        public List<RecentMenuEntry> RecentEntries { get; set; } = new();
        public List<WeeklyMenu> WeeklyMenus { get; set; } = new();
        public List<User> AvailableCooks { get; set; } = new();

        // Ny lista för översikt
        public List<WeeklyMenuViewModel> PreviousWeeks { get; set; } = new();
        public class RecentMenuEntry
        {
            public DateTime Date { get; set; }
            public string BreakfastMealName { get; set; }
            public string LunchMealName { get; set; }
            public string DinnerMealName { get; set; }
        }


        public WeeklyMenu GetMealEntry(int day, string type)
        {
            int dayOfWeek = day + 1;
            return WeeklyMenus.FirstOrDefault(m =>
                m.DayOfWeek == dayOfWeek &&
                (
                    (type == "Frukost" && m.BreakfastMealId.HasValue) ||
                    (type == "Lunch" && m.LunchMealId.HasValue) ||
                    (type == "Middag" && m.DinnerMealId.HasValue)
                )
            );
        }
    }


}
