using System.ComponentModel.DataAnnotations;

namespace MealPlan.Api.DTOs.Recipe;

/// <summary>Payload for creating or updating a recipe with nested ingredients and steps.</summary>
public class CreateRecipeDto
{
    [Required]
    [MaxLength(255)]
    public string Name { get; set; } = string.Empty;

    /// <summary>0 = Breakfast, 1 = SecondBreakfast, 2 = Lunch, 3 = Dinner.</summary>
    [Range(0, 3)]
    public int MealCategory { get; set; }

    [Range(0, 100000)]
    public int? Calories { get; set; }

    [Range(0, 10000)]
    public decimal? Protein { get; set; }

    [Range(0, 10000)]
    public decimal? Fat { get; set; }

    [Range(0, 10000)]
    public decimal? Carbs { get; set; }

    [Range(0, 100000)]
    public int? PrepTimeMinutes { get; set; }

    public List<CreateIngredientDto> Ingredients { get; set; } = new();
    public List<CreateRecipeStepDto> Steps { get; set; } = new();
}

public class CreateIngredientDto
{
    [Required]
    [MaxLength(255)]
    public string Name { get; set; } = string.Empty;

    [Range(0, 100000)]
    public decimal? AmountGrams { get; set; }

    [MaxLength(50)]
    public string? Unit { get; set; }

    public int? CatalogItemId { get; set; }

    public int SortOrder { get; set; }
}

public class CreateRecipeStepDto
{
    [Range(1, 1000)]
    public int StepNumber { get; set; }

    [Required]
    public string Description { get; set; } = string.Empty;
}
