Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
2
Indexable
Never
SimilarFilmsIndex

@inject IAdminService AdminService
<table class="table mt-2">
    <thead>
        <tr>
            <th>Film Name </th>
            <th>Similar Films</th>
            <th></th>
        </tr>
    </thead>
    <tbody>

        @foreach (var item in Model.OrderBy(x => x.FilmId))
        {
            <tr>
                <td>@Films.FirstOrDefault(f => f.Id == item.FilmId)?.Title</td>
                <td>@Films.FirstOrDefault(f => f.Id == item.SimilarFilmId)?.Title</td>
                <td>
                    <div class="d-flex me-1 justify-content-end">
                        <button class="btn btn-outline-danger rounded-0" @onclick="@(() => OnClick.InvokeAsync(new ClickReferenceModel(PageType.Delete, item.FilmId, item.SimilarFilmId)))">Delete</button>
                    </div>
                </td>
            </tr>
        }   
    </tbody>
</table>
@code {

    [Parameter] public List<SimilarFilmsDTO> Model { get; set; } = new(); [Parameter] public EventCallback<ClickReferenceModel> OnClick { get; set; }
    [Parameter] public List<FilmDTO> Films { get; set; } = new(); protected override async Task OnInitializedAsync() { Films = await AdminService.GetAsync<FilmDTO>("films"); }
}