using MediatR;
using System.ComponentModel.DataAnnotations;

namespace MembershipService.API.Application.Commands;

/// <summary>
/// EN: Command to create a new level definition.
/// VI: Command để tạo level definition mới.
/// </summary>
public class CreateLevelDefinitionCommand : IRequest<CreateLevelDefinitionResult>
{
    /// <summary>
    /// EN: Level number (1, 2, 3...).
    /// VI: Số thứ tự level (1, 2, 3...).
    /// </summary>
    [Required]
    [Range(1, 100)]
    public int LevelNumber { get; set; }

    /// <summary>
    /// EN: Level name (Bronze, Silver, Gold...).
    /// VI: Tên level (Bronze, Silver, Gold...).
    /// </summary>
    [Required]
    [StringLength(100, MinimumLength = 1)]
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// EN: Required EXP to reach this level.
    /// VI: EXP cần thiết để đạt level này.
    /// </summary>
    [Required]
    [Range(0, int.MaxValue)]
    public int RequiredExp { get; set; }

    /// <summary>
    /// EN: Level description.
    /// VI: Mô tả level.
    /// </summary>
    [StringLength(500)]
    public string? Description { get; set; }

    /// <summary>
    /// EN: Icon URL for the level badge.
    /// VI: URL icon cho badge level.
    /// </summary>
    [StringLength(500)]
    public string? IconUrl { get; set; }

    /// <summary>
    /// EN: Badge color in hex format (#CD7F32, #FFD700...).
    /// VI: Màu badge dạng hex (#CD7F32, #FFD700...).
    /// </summary>
    [StringLength(20)]
    [RegularExpression(@"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$", ErrorMessage = "Invalid hex color format")]
    public string? BadgeColor { get; set; }
}

/// <summary>
/// EN: Result of creating a level definition.
/// VI: Kết quả tạo level definition.
/// </summary>
public class CreateLevelDefinitionResult
{
    public Guid Id { get; set; }
    public int LevelNumber { get; set; }
    public string Name { get; set; } = string.Empty;
    public int RequiredExp { get; set; }
    public DateTime CreatedAt { get; set; }
}
