@using crud.Models

@model IEnumerable<crud.Models.Category>

@{
    ViewBag.Title = "Lista de categorías";
}

@Html.Partial("_AlertNotify")
@Html.Partial("_PopupNotify", "Contenido copiado al portapapeles")

@Styles.Render("~/Content/datatables")
@Styles.Render("~/Content/datatables-buttons")

<h3>@ViewBag.Title</h3>
<p>@ViewBag.Message</p>
<div>
    @using (Html.BeginForm("Create", "Category", FormMethod.Get))
    {
        <button type="submit" class="btn btn-success btn-sm px-3">Agregar</button>
    }
</div>
<br />
<div class="table-responsive">
    <table id="table-categories" class="table table-striped">
        <thead>
            <tr>
                <th scope="col">#</th>
                <th scope="col">Nombre</th>
                <th scope="col">Artículos relacionados</th>
                <th scope="col">Acción</th>
            </tr>
        </thead>
        <tbody>
            @foreach (Category category in Model)
            {
                <tr>
                    <th scope="row">@Html.DisplayFor(model => category.Id)</th>
                    <td>@Html.DisplayFor(model => category.Name)</td>
                    <td>@Html.DisplayFor(model => category.Articles.Count)</td>
                    <td class="py-1">
                        @Html.Partial("_ActionButtons", category)
                    </td>
                </tr>
            }
        </tbody>
    </table>
    <p>Total: @Model.Count()</p>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/datatables-categories")
    @Scripts.Render("~/bundles/datatables-buttons")
}