namespace BackOffice.Services.PublicMessage;

public interface IPublicMessageService
{
    Task<(List<PublicMessageDto> Messages, int TotalCount)> GetMessagesAsync(MessageFilterDto? filter = null);
    Task<PublicMessageDetailsDto?> GetByIdAsync(long id);
    Task<long> CreateAsync(CreatePublicMessageDto dto);
    Task UpdateAsync(long id, UpdatePublicMessageDto dto);
    Task DeleteAsync(long id);
    Task PublishAsync(long id);
    Task ArchiveAsync(long id);
}

public class MessageFilterDto
{
    public MessageStatus? Status { get; set; }
    public MessageType? Type { get; set; }
    public int PageNumber { get; set; } = 1;
    public int PageSize { get; set; } = 20;
}

public enum MessageType
{
    Announcement = 0,
    News = 1,
    Alert = 2,
    Promotion = 3
}

public enum MessageStatus
{
    Draft = 0,
    Published = 1,
    Archived = 2
}

public class PublicMessageDto
{
    public long Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public MessageType Type { get; set; }
    public string TypeName { get; set; } = string.Empty;
    public int Priority { get; set; }
    public string PriorityName { get; set; } = string.Empty;
    public MessageStatus Status { get; set; }
    public string StatusName { get; set; } = string.Empty;
    public DateTime? StartsAt { get; set; }
    public DateTime? ExpiresAt { get; set; }
    public DateTime? Created { get; set; }
}

public class PublicMessageDetailsDto
{
    public long Id { get; set; }
    public string Title { get; set; } = string.Empty;
    public string Content { get; set; } = string.Empty;
    public MessageType Type { get; set; }
    public string TypeName { get; set; } = string.Empty;
    public int Priority { get; set; }
    public string PriorityName { get; set; } = string.Empty;
    public MessageStatus Status { get; set; }
    public string StatusName { get; set; } = string.Empty;
    public DateTime? StartsAt { get; set; }
    public DateTime? ExpiresAt { get; set; }
    public DateTime? PublishedAt { get; set; }
    public DateTime? ArchivedAt { get; set; }
    public bool IsDismissible { get; set; }
    public string? TargetAudience { get; set; }
    public List<string> Tags { get; set; } = new();
    public DateTime? Created { get; set; }
    public DateTime? LastModified { get; set; }
}

public class CreatePublicMessageDto
{
    public string Title { get; set; } = string.Empty;
    public string Content { get; set; } = string.Empty;
    public MessageType Type { get; set; }
    public int Priority { get; set; } = 1;
    public DateTime? StartsAt { get; set; }
    public DateTime? ExpiresAt { get; set; }
    public bool IsDismissible { get; set; } = true;
    public string? TargetAudience { get; set; }
    public List<string>? Tags { get; set; }
}

public class UpdatePublicMessageDto
{
    public string Title { get; set; } = string.Empty;
    public string Content { get; set; } = string.Empty;
    public MessageType Type { get; set; }
    public int Priority { get; set; }
    public DateTime? StartsAt { get; set; }
    public DateTime? ExpiresAt { get; set; }
    public bool IsDismissible { get; set; }
    public string? TargetAudience { get; set; }
    public List<string>? Tags { get; set; }
}
