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

namespace MealPlan.Api.Models;

[Table("DietGeneratorSessions")]
public class DietGeneratorSession
{
    [Column("Id")]
    public int Id { get; set; }

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

    [Column("Status")]
    [MaxLength(32)]
    public string Status { get; set; } = DietGeneratorStatuses.MacrosPending;

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

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

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

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

    [Column("MacroRationale")]
    public string? MacroRationale { get; set; }

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

    [Column("PlanStartDate")]
    public DateOnly? PlanStartDate { get; set; }

    [Column("PlanDayCount")]
    public int PlanDayCount { get; set; } = 7;

    [Column("CalorieToleranceKcal")]
    public int CalorieToleranceKcal { get; set; } = 10;

    [Column("PreferencesJson")]
    public string? PreferencesJson { get; set; }

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

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

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

    public ICollection<DietGeneratorDraftMeal> DraftMeals { get; set; } = new List<DietGeneratorDraftMeal>();
}

public static class DietGeneratorStatuses
{
    public const string MacrosPending = "macros_pending";
    public const string MacrosAccepted = "macros_accepted";
    public const string PlanDraft = "plan_draft";
    public const string Committed = "committed";
    public const string Abandoned = "abandoned";
}
