@model IEnumerable<User>
@{
    ViewData["Title"] = "Пользователи";
}

<div class="container p-4 border">
    <div class="row pb-2">
        <div class="col">
            <h1 class="text-primary">Список пользователей</h1>
        </div>

        <div class="col text-end pt-1">
            <a asp-action="Create" class="btn btn-outline-primary">
                <i class="fa-solid fa-plus"></i> Добавить пользователя
            </a>
        </div>
    </div>

    <table class="table">
        <thead>
            <tr>
                <th>Имя</th>
                <th>Телефон</th>
                <th>Должность</th>
                <th></th>
            </tr>
        </thead>

        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>
                        <a asp-action="Details" class="align-middle" asp-route-id="@item.UserId">
                            @item.Name
                        </a>
                    </td>

                    <td>
                        @item.Phone
                    </td>

                    <td>
                        @item.Position
                    </td>

                    <td>
                        <a asp-action="Edit" class="btn btn-success" asp-route-id="@item.UserId">
                            <i class="fa-solid fa-edit"></i>
                        </a>
                        <a asp-action="Delete" class="btn btn-danger" asp-route-id="@item.UserId">
                            <i class="fa-solid fa-trash"></i>
                        </a>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>

@section Scripts {
    @{
        await Html.RenderPartialAsync("_ValidationScriptsPartial");
    }
}
