namespace BackOffice.Services.Blog;

public interface IBlogPostService
{
    Task<BlogPostListResultDto> GetAllAsync(BlogPostFilterDto filter);
    Task<BlogPostDetailsDto?> GetByIdAsync(long id);
    Task<long> CreateAsync(BlogPostEditDto dto);
    Task UpdateAsync(long id, BlogPostEditDto dto);
    Task DeleteAsync(long id);
    Task<PublishResultDto> PublishAsync(long id);
    Task<ArchiveResultDto> ArchiveAsync(long id);
}

public class BlogPostFilterDto
{
    public int PageNumber { get; set; } = 1;
    public int PageSize { get; set; } = 20;
    public string? SearchTerm { get; set; }
    public int? Status { get; set; }
    public long? CategoryId { get; set; }
    public bool? IsFeatured { get; set; }
}

public class BlogPostListResultDto
{
    public List<BlogPostListItemDto> Items { get; set; } = new();
    public int TotalCount { get; set; }
}

public class BlogPostListItemDto
{
    public long Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public string Slug { get; set; } = string.Empty;
    public string? Summary { get; set; }
    public string? FeaturedImageThumbnailPath { get; set; }
    public int Status { get; set; }
    public string StatusName { get; set; } = string.Empty;
    public DateTime? PublishedAt { get; set; }
    public int ViewCount { get; set; }
    public bool IsFeatured { get; set; }
    public DateTime Created { get; set; }
    public List<BlogPostCategoryInfoDto> Categories { get; set; } = new();
}

public class BlogPostCategoryInfoDto
{
    public long Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public string Slug { get; set; } = string.Empty;
}

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

public class BlogPostDetailsDto
{
    public long Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public string Slug { get; set; } = string.Empty;
    public string? Summary { get; set; }
    public string HtmlContent { get; set; } = string.Empty;
    public string? FeaturedImagePath { get; set; }
    public string? FeaturedImageThumbnailPath { get; set; }
    public int Status { get; set; }
    public string StatusName { get; set; } = string.Empty;
    public DateTime? PublishedAt { get; set; }
    public int ViewCount { get; set; }
    public long AuthorUserId { get; set; }
    public bool IsFeatured { get; set; }
    public int SortOrder { get; set; }
    public DateTime Created { get; set; }
    public DateTime LastModified { get; set; }
    public List<BlogPostCategoryInfoDto> Categories { get; set; } = new();
    public List<BlogPostTagInfoDto> Tags { get; set; } = new();
}

public class BlogPostEditDto
{
    public string Title { get; set; } = string.Empty;
    public string Slug { get; set; } = string.Empty;
    public string? Summary { get; set; }
    public string HtmlContent { get; set; } = string.Empty;
    public string? FeaturedImagePath { get; set; }
    public string? FeaturedImageThumbnailPath { get; set; }
    public List<long> CategoryIds { get; set; } = new();
    public List<long> TagIds { get; set; } = new();
    public bool IsFeatured { get; set; }
    public int SortOrder { get; set; }

    // Image upload properties
    public byte[]? ImageFile { get; set; }
    public string? ImageMime { get; set; }
    public string? ImageFileName { get; set; }
}

public class PublishResultDto
{
    public bool Success { get; set; }
    public string Message { get; set; } = string.Empty;
    public DateTime? PublishedAt { get; set; }
}

public class ArchiveResultDto
{
    public bool Success { get; set; }
    public string Message { get; set; } = string.Empty;
}
