namespace BackOffice.Services.DiscountProduct;

public interface IDiscountProductService
{
    Task<(List<DiscountProductDto> Products, int TotalCount, int TotalPages)> GetProductsAsync(ProductFilterDto? filter = null);
    Task<DiscountProductDetailDto?> GetByIdAsync(long id, long? userId = null);
    Task<long> CreateAsync(CreateDiscountProductDto dto);
    Task UpdateAsync(long id, UpdateDiscountProductDto dto);
    Task DeleteAsync(long id);
}

public class ProductFilterDto
{
    public string? SearchQuery { get; set; }
    public long? CategoryId { get; set; }
    public long? MinPrice { get; set; }
    public long? MaxPrice { get; set; }
    public bool? IsActive { get; set; }
    public bool? InStock { get; set; }
    public int PageNumber { get; set; } = 1;
    public int PageSize { get; set; } = 20;
}

public class DiscountProductDto
{
    public long Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public string? ShortInformation { get; set; }
    public long Price { get; set; }
    public int MaxDiscountPercent { get; set; }
    public string? ImagePath { get; set; }
    public string? ThumbnailPath { get; set; }
    public int RemainingCount { get; set; }
    public int ViewCount { get; set; }
    public bool IsActive { get; set; }
    public DateTime? Created { get; set; }
}

public class DiscountProductDetailDto
{
    public long Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public string? ShortInformation { get; set; }
    public string? FullInformation { get; set; }
    public long Price { get; set; }
    public int MaxDiscountPercent { get; set; }
    public string? ImagePath { get; set; }
    public string? ThumbnailPath { get; set; }
    public int RemainingCount { get; set; }
    public int ViewCount { get; set; }
    public int SortOrder { get; set; }
    public bool IsActive { get; set; }
    public List<CategoryInfoDto> Categories { get; set; } = new();
    public DateTime? Created { get; set; }
}

public class CategoryInfoDto
{
    public long Id { get; set; }
    public string Name { get; set; } = string.Empty;
    public string Title { get; set; } = string.Empty;
}

public class CreateDiscountProductDto
{
    public string Title { get; set; } = string.Empty;
    public string? ShortInformation { get; set; }
    public string? FullInformation { get; set; }
    public long Price { get; set; }
    public int MaxDiscountPercent { get; set; }
    public string? ImagePath { get; set; }
    public string? ThumbnailPath { get; set; }
    public int InitialCount { get; set; }
    public int SortOrder { get; set; }
    public bool IsActive { get; set; } = true;
    public List<long>? CategoryIds { get; set; }
    
    // Image upload support
    public byte[]? ImageFile { get; set; }
    public string? ImageMime { get; set; }
    public string? ImageFileName { get; set; }
    public byte[]? ThumbnailFile { get; set; }
    public string? ThumbnailMime { get; set; }
    public string? ThumbnailFileName { get; set; }
}

public class UpdateDiscountProductDto
{
    public string Title { get; set; } = string.Empty;
    public string? ShortInformation { get; set; }
    public string? FullInformation { get; set; }
    public long Price { get; set; }
    public int MaxDiscountPercent { get; set; }
    public string? ImagePath { get; set; }
    public string? ThumbnailPath { get; set; }
    public int SortOrder { get; set; }
    public bool IsActive { get; set; }
    public List<long>? CategoryIds { get; set; }
    
    // Image upload support
    public byte[]? ImageFile { get; set; }
    public string? ImageMime { get; set; }
    public string? ImageFileName { get; set; }
    public byte[]? ThumbnailFile { get; set; }
    public string? ThumbnailMime { get; set; }
    public string? ThumbnailFileName { get; set; }
}

