@model IEnumerable<Location>
@{
    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>
            </tr>
        </thead>

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

                     <td>
                         @item.Address
                     </td>

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

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