@page "/voc"
@attribute [Authorize(Roles = "teacher")]
@using adminBlazor.Models



<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">

<link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bootstrap/blazorise.bootstrap.css" rel="stylesheet" />
<h3>Vocabulary Lists</h3>

<DataGrid TItem="VocabularyList"
          Data="@_vocList"
          ReadData="@OnReadData"
          TotalItems="@totalVocList"
          PageSize="10"
          ShowPager
          Responsive>

    <DataGridColumn TItem="VocabularyList" Field="@nameof(VocabularyList.Id)" Caption="id" />
    <DataGridColumn TItem="VocabularyList" Field="@nameof(VocabularyList.Name)" Caption="Name" />
    <DataGridColumn TItem="VocabularyList" Field="@nameof(VocabularyList.Image)" Caption="Image" />
    <DataGridColumn TItem="VocabularyList" Field="@nameof(VocabularyList.Aut)" Caption="Author ID">
        <DisplayTemplate>
            @if (context is VocabularyList voc)
            {
                @if (voc.Aut != null)
                {
                    @voc.Aut
                }
                else
                {
                    <span>No author</span>
                }
            }
        </DisplayTemplate>
    </DataGridColumn>

    <DataGridColumn TItem="VocabularyList" Field="@nameof(VocabularyList.Id)" Caption="Modifier">
        <DisplayTemplate>
            <a href="editVoc/@(context.Id)" class="btn btn-primary"><i class="fa fa-edit"></i> Editer</a>
            <button type="button" class="btn btn-primary" @onclick="() => OnDelete(context.Id)"><i class="fa fa-trash"></i> Supprimer</button>
        </DisplayTemplate>
    </DataGridColumn>
</DataGrid>
