using System.ComponentModel.DataAnnotations;
using LittleShop.Enums;

namespace LittleShop.DTOs;

public class ProductDto
{
    public Guid Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
    public decimal Price { get; set; }
    public decimal Weight { get; set; }
    public ProductWeightUnit WeightUnit { get; set; }
    public int StockQuantity { get; set; }
    public Guid CategoryId { get; set; }
    public string CategoryName { get; set; } = string.Empty;
    public DateTime CreatedAt { get; set; }
    public DateTime UpdatedAt { get; set; }
    public bool IsActive { get; set; }
    public List<ProductPhotoDto> Photos { get; set; } = new();
}

public class ProductPhotoDto
{
    public Guid Id { get; set; }
    public string FileName { get; set; } = string.Empty;
    public string FilePath { get; set; } = string.Empty;
    public string? AltText { get; set; }
    public int SortOrder { get; set; }
}

public class CreateProductDto
{
    [Required]
    [StringLength(200)]
    public string Name { get; set; } = string.Empty;
    
    [Required(AllowEmptyStrings = true)]
    public string Description { get; set; } = string.Empty;
    
    [Required]
    [Range(0.01, double.MaxValue, ErrorMessage = "Price must be greater than 0")]
    public decimal Price { get; set; }
    
    [Required]
    [Range(0.01, double.MaxValue, ErrorMessage = "Weight must be greater than 0")]
    public decimal Weight { get; set; }
    
    public ProductWeightUnit WeightUnit { get; set; } = ProductWeightUnit.Grams;
    
    [Range(0, int.MaxValue)]
    public int StockQuantity { get; set; } = 0;
    
    [Required(ErrorMessage = "Please select a category")]
    public Guid CategoryId { get; set; }
}

public class UpdateProductDto
{
    [StringLength(200)]
    public string? Name { get; set; }
    
    public string? Description { get; set; }
    
    [Range(0.01, double.MaxValue)]
    public decimal? Price { get; set; }
    
    public decimal? Weight { get; set; }
    
    public ProductWeightUnit? WeightUnit { get; set; }
    
    [Range(0, int.MaxValue)]
    public int? StockQuantity { get; set; }
    
    public Guid? CategoryId { get; set; }
    
    public bool? IsActive { get; set; }
}

public class CreateProductPhotoDto
{
    [Required]
    public Guid ProductId { get; set; }
    
    [Required]
    public string PhotoUrl { get; set; } = string.Empty;
    
    public string? AltText { get; set; }
    
    public int DisplayOrder { get; set; }
}