using MediatR;
using System.ComponentModel.DataAnnotations;

namespace MembershipService.API.Application.Commands;

/// <summary>
/// EN: Command to update an existing level definition.
/// VI: Command để cập nhật level definition.
/// </summary>
public class UpdateLevelDefinitionCommand : IRequest<UpdateLevelDefinitionResult>
{
    /// <summary>
    /// EN: Level definition ID.
    /// VI: ID của level definition.
    /// </summary>
    [Required]
    public Guid Id { get; set; }

    /// <summary>
    /// EN: Level name (optional, only updates if provided).
    /// VI: Tên level (optional, chỉ cập nhật nếu có).
    /// </summary>
    [StringLength(100, MinimumLength = 1)]
    public string? Name { get; set; }

    /// <summary>
    /// EN: Required EXP (optional, only updates if provided).
    /// VI: EXP yêu cầu (optional, chỉ cập nhật nếu có).
    /// </summary>
    [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.
    /// VI: Màu badge dạng hex.
    /// </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: Whether to clear description.
    /// VI: Có xóa description không.
    /// </summary>
    public bool ClearDescription { get; set; }

    /// <summary>
    /// EN: Whether to clear icon URL.
    /// VI: Có xóa icon URL không.
    /// </summary>
    public bool ClearIconUrl { get; set; }

    /// <summary>
    /// EN: Whether to clear badge color.
    /// VI: Có xóa badge color không.
    /// </summary>
    public bool ClearBadgeColor { get; set; }
}

/// <summary>
/// EN: Result of updating a level definition.
/// VI: Kết quả cập nhật level definition.
/// </summary>
public class UpdateLevelDefinitionResult
{
    public Guid Id { get; set; }
    public int LevelNumber { get; set; }
    public string Name { get; set; } = string.Empty;
    public int RequiredExp { get; set; }
    public string? Description { get; set; }
    public string? IconUrl { get; set; }
    public string? BadgeColor { get; set; }
    public bool IsActive { get; set; }
    public DateTime UpdatedAt { get; set; }
}
