@using CD67.FicheCollege.MVC.Models
@model ActionEduAxeIndexViewModel

@{
    ViewBag.Title = "Axes";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
    int maxOrdre = Model.Obj.Count() == 0 ? 0 : Model.Obj.Max(i => i.Ordre);
    int row = 1;
}

<h2>Axes</h2>

<p>
    <a href="@Url.Action("Create")">
        <span class="glyphicon glyphicon-plus-sign fa-2x color1" style="vertical-align: middle" aria-hidden="true"></span>
        Créer un nouvel élément
    </a>
</p>

<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Obj.First().Nom)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Obj.First().Neutralise)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model.Obj.OrderBy(i => i.Ordre))
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Nom)
            </td>
        
            <td>
                @Html.DisplayFor(modelItem => item.Neutralise)
            </td>

            <td>
                @if (row != 1)
                    {
                    <a href="@Url.Action("Up", new { id = item.Id })">
                        <span class="glyphicon glyphicon-circle-arrow-up fa-2x color1" title="Remonter" style="vertical-align: middle" aria-hidden="true"></span>
                    </a>
                }
                else
                {
                    <span class="glyphicon glyphicon-circle-arrow-up fa-2x color2" title="Remonter" style="vertical-align: middle" aria-hidden="true"></span>
                }
                @if (item.Ordre != maxOrdre)
                    {
                    <a href="@Url.Action("Down", new { id = item.Id })">
                        <span class="glyphicon glyphicon-circle-arrow-down fa-2x color1" title="Descendre" style="vertical-align: middle" aria-hidden="true"></span>
                    </a>
                }
                else
                {
                    <span class="glyphicon glyphicon-circle-arrow-down fa-2x color2" title="Descendre" style="vertical-align: middle" aria-hidden="true"></span>
                }
                <a href="@Url.Action("Edit", new { id = item.Id })">
                    <span class="glyphicon glyphicon-edit fa-2x color1" title="Modifier" style="vertical-align: middle" aria-hidden="true"></span>
                </a>
                <a href="@Url.Action("Delete", new { id = item.Id })">
                    <span class="glyphicon glyphicon-remove-sign fa-2x color1" title="Supprimer" style="vertical-align: middle" aria-hidden="true"></span>
                </a>
            </td>
        </tr>
        row += 1;
    }

</table>
