namespace BackOffice.Services.AppVersion;

public interface IAppVersionService
{
    Task<List<AppVersionDto>> GetAllAsync(bool includeInactive = false);
    Task<AppVersionDto?> GetByNameAsync(string appName);
    Task UpdateAsync(UpdateAppVersionDto dto);
}

public class AppVersionDto
{
    public long Id { get; set; }
    public string AppName { get; set; } = string.Empty;
    public string AppNameDisplay => GetDisplayName(AppName);
    public string CurrentVersion { get; set; } = string.Empty;
    public string MinRequiredVersion { get; set; } = string.Empty;
    public bool RequiresFullCacheClear { get; set; }
    public string UpdateMessage { get; set; } = string.Empty;
    public string ReleaseNotes { get; set; } = string.Empty;
    public bool IsActive { get; set; }
    public DateTime? Created { get; set; }
    public DateTime? LastModified { get; set; }
    
    private static string GetDisplayName(string appName) => appName switch
    {
        "FoursatMarketApp" => "اپ مارکت فورست",
        "FoursatClubApp" => "اپ باشگاه فورست",
        _ => appName
    };
}

public class UpdateAppVersionDto
{
    public string AppName { get; set; } = string.Empty;
    public string CurrentVersion { get; set; } = string.Empty;
    public string? MinRequiredVersion { get; set; }
    public bool RequiresFullCacheClear { get; set; }
    public string? UpdateMessage { get; set; }
    public string? ReleaseNotes { get; set; }
    public string? UpdateReason { get; set; }
}
