using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using Aberwyn.Data;
using Aberwyn.Models;

namespace Aberwyn.Models
{
    public class MenuViewModel
    {
        public List<Meal> Meals { get; set; }  // List of all available meals
        public List<WeeklyMenu> WeeklyMenus { get; set; }  // List of weekly menu entries
        public int WeekNumber { get; set; }  // Week number for the menu
        public int Year { get; set; }  // Year for the menu
    }
public class WeeklyMenu
{
    public int Id { get; set; }
    public int DayOfWeek { get; set; }
    public int? BreakfastMealId { get; set; }
    public int? LunchMealId { get; set; }
    public int? DinnerMealId { get; set; }
    public string? Cook { get; set; }
    public int WeekNumber { get; set; }
    public int Year { get; set; }
    public DateTime CreatedAt { get; set; }

        [NotMapped] public string? BreakfastMealName { get; set; }
    [NotMapped] public string? LunchMealName { get; set; }
    [NotMapped] public string? DinnerMealName { get; set; }


}



    public class RecentMenuEntry
    {
        public DateTime Date { get; set; }
        public string BreakfastMealName { get; set; }
        public string LunchMealName { get; set; }
        public string DinnerMealName { get; set; }
    }
public class Meal
{
    public int Id { get; set; }
    public string Name { get; set; } // Behåll som obligatorisk

    public string? Description { get; set; }
    public string? ProteinType { get; set; }
    public string? Category { get; set; }
    public string? CarbType { get; set; }
    public string? RecipeUrl { get; set; }
    public string? ImageUrl { get; set; }
    public bool IsAvailable { get; set; }
    public DateTime CreatedAt { get; set; }

    public byte[]? ImageData { get; set; }         // 👈 Viktigt!
    public string? ImageMimeType { get; set; }     // 👈 Viktigt!
    public string? Instructions { get; set; }      // 👈 Viktigt!

    public List<Ingredient> Ingredients { get; set; } = new();
}

    public class Ingredient
    {
        public int Id { get; set; }
        public int MealId { get; set; }
        public string Quantity { get; set; }
        public string Item { get; set; }
    }

    public class MealDto
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Category { get; set; }
        public bool IsAvailable { get; set; }
        public string? ImageUrl { get; set; }
        public string? ImageData { get; set; } // base64
        public string? ImageMimeType { get; set; }

        public static MealDto FromMeal(Meal meal)
        {
            return new MealDto
            {
                Id = meal.Id,
                Name = meal.Name,
                Category = meal.Category,
                IsAvailable = meal.IsAvailable,
                ImageUrl = meal.ImageUrl,
                ImageMimeType = meal.ImageMimeType,
                ImageData = meal.ImageData != null ? Convert.ToBase64String(meal.ImageData) : null
            };
        }
    }

}

