using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace MealPlan.Api.Models;

/// <summary>
/// Maps to the existing "Recipes" table. Database-first; no migrations manage this table.
/// </summary>
[Table("Recipes")]
public class Recipe
{
    [Column("Id")]
    public int Id { get; set; }

    [Column("Name")]
    [MaxLength(255)]
    public string Name { get; set; } = string.Empty;

    /// <summary>Stored as INT in the DB (0..3). Mapped to the <see cref="MealCategory"/> enum.</summary>
    [Column("MealCategory")]
    public int MealCategory { get; set; }

    [Column("Calories")]
    public int? Calories { get; set; }

    [Column("Protein")]
    public decimal? Protein { get; set; }

    [Column("Fat")]
    public decimal? Fat { get; set; }

    [Column("Carbs")]
    public decimal? Carbs { get; set; }

    [Column("PrepTimeMinutes")]
    public int? PrepTimeMinutes { get; set; }

    [Column("CreatedAt")]
    public DateTime CreatedAt { get; set; }

    [Column("UpdatedAt")]
    public DateTime? UpdatedAt { get; set; }

    [Column("IsActive")]
    public bool IsActive { get; set; }

    [Column("Source")]
    [MaxLength(32)]
    public string Source { get; set; } = "manual";

    [Column("CreatedByUserId")]
    public Guid? CreatedByUserId { get; set; }

    [Column("IsDraft")]
    public bool IsDraft { get; set; }

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