@page
@model MyBookmark.UI.RazorPages.Pages.Library.Anime.AnimeTitleListModel

<h1>Медиа</h1>
<div class="row justify-content-end">
    <div class="col-auto">
        <form method="post">
            <div class="input-group mb-3">
                <span class="input-group-text" id="basic-addon1">Название</span>
                <input type="text" class="form-control w-25" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon1">
                <select class="form-select" aria-label="Default select example" id="basic-addon1">
                    <option value="@null" selected>Язык</option>
                    @foreach (var language in Model.Languages)
                    {
                        <option value=@language.Id>[@language.CodeIso3] @language.Name</option>
                    }
                </select>
                <button class="btn btn-outline-primary" type="submit" id="button-addon2">Button</button>
            </div>
        </form>
    </div>
</div>

@if (!Model.AnimeTitles.Any())
{
    <h2>Нет тайтлов...</h2>
}
else
{
    @foreach (var animeTitle in Model.AnimeTitles)
    {
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col">
                        @* <h4 class="nav-link card-title" onclick=@(()=>ShowDetails(animeTitles.Id))> *@
                        <h4 class="nav-link card-title" )>
                            @{
                                var name = animeTitle.CommonProperties.Names.FirstOrDefault()?.Value;
                                @(!string.IsNullOrWhiteSpace(name) ? name : "Нет названия")
                            }
                        </h4>
                        <br />
                        <h5>Жанры</h5>
                        <div class="row gap-2 border border-2 border-start-0 border-end-0 py-2">
                            @if (animeTitle.CommonProperties.Genres.Any())
                            {
                                @foreach (var genre in animeTitle.CommonProperties.Genres)
                                {
                                    <div class="col-auto border rounded-pill border-secondary bg-black bg-opacity-25">@genre.Genre.Name</div>
                                }
                            }
                            else
                            {
                                <div class="col-auto border rounded-pill border-secondary bg-black bg-opacity-25">— /./././ —</div>
                            }
                        </div>
                        <br />
                        @* <RatingComponent RatingSubject=@userService.GetUser() RatableObject="mediaContent" /> *@
                        <br />
                        <p class="card-text">
                            @(animeTitle.CommonProperties.Descriptions.FirstOrDefault()?.Value ?? "No description")
                        </p>

                        <br />
                        <h5>Сезонов: @(animeTitle.Episodes.Count)</h5>
                        <br />
                        <h5>Эпизодов: @(animeTitle.EpisodesInsideSeasonsCount)@(animeTitle.Episodes.Count > 0 ? $" + {animeTitle.Episodes.Count}" : string.Empty)</h5>

                        @* <span class="card-subtitle">@GetMediaContentDateString(animeTitles)</span> *@
                    </div>
                    <div class="col-2">
                        <ImagePreview PreviewUrl=@(animeTitle.CommonProperties.Preview?.Url ?? string.Empty) />
                    </div>
                </div>
            </div>
        </div>
    }
}


@{

}
