@model IEnumerable<Data.Entities.Rents>

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

<h1>Rents</h1>

<p>
    <a type="button" class="btn btn-primary" asp-action="Create">Rent a car</a>
</p>
@if (this.User.IsInRole("Admin"))
{
    <table class="table table-striped">
        <thead>
            <tr>
                <th>
                    @Html.DisplayNameFor(model => model.Car.Id)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.StartDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.EndDate)
                </th>
                <th>
                    @Html.DisplayNameFor(model => model.User.UserName)
                </th>
                @if (this.User.IsInRole("Admin"))
                {
                    <th>
                        Actions
                    </th>
                }
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Car.Id)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.StartDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.EndDate)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.User.UserName)
                    </td>
                    @if (this.User.IsInRole("Admin"))
                    {
                        <td>
                            <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
                            <a asp-action="Details" asp-route-id="@item.Id">Details</a> |
                            <a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
                        </td>
                    }
                </tr>
            }
        </tbody>
    </table>
}