using Microsoft.AspNetCore.Mvc.RazorPages;
using MyBookmark.UI.RazorPages.Clients.Library.Language;
using MyBookmark.UI.RazorPages.Clients.Library.MediaContent.Anime.Title;

namespace MyBookmark.UI.RazorPages.Pages.Library.Anime;

public class AnimeTitleListModel : PageModel
{
    private readonly ITitleClient _titleClient;
    private readonly ILanguageClient _languageClient;
    public List<Clients.Library.Language.Language> Languages { get; set; } = [];
    public List<Title> AnimeTitles { get; set; } = [];


    public AnimeTitleListModel(ITitleClient titleClient, ILanguageClient languageClient)
    {
        _titleClient = titleClient;
        _languageClient = languageClient;
    }

    
    public async Task OnGet()
    {
        Languages.Clear();
        Languages.AddRange(await _languageClient.ListAsync());
        await LoadTitles();
    }

    private async Task LoadTitles()
    {
        AnimeTitles.Clear();
        AnimeTitles.AddRange(await _titleClient.ListAsync());
    }
}
