
@model isnd.Data.ApiKeys.IndexModel

@{
    ViewData["Title"] = "Index";
}

<h2>Index</h2>

<p>
    <a asp-controller="ApiKeys" asp-action="Create">Create New</a>
</p>
<table class="table">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.ApiKey[0].User)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.ApiKey[0].Name)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.ApiKey[0].CreationDate)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.ApiKey[0].ValidityPeriodInDays)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
@foreach (var item in Model.ApiKey) {
        var rcsscl = item.IsValid ?
         item.CreationDate.AddDays(item.ValidityPeriodInDays-30) > DateTime.Now ?
         "ok" : "nomoretam" : "expired";
    
        <tr class="@rcsscl">
            <td>
                @Html.DisplayFor(modelItem => item.User.Id)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.CreationDate)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ValidityPeriodInDays)
            </td>
            <td>
                <a asp-controller="ApiKeys"  asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
                <a asp-controller="ApiKeys"  asp-action="Details" asp-route-id="@item.Id">Details</a> |
                <a asp-controller="ApiKeys"  asp-action="Delete" asp-route-id="@item.Id">Delete</a>
            </td>
        </tr>
}
    </tbody>
</table>
