@model IEnumerable<SuperShop.Web.Data.Entities.Order>

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

<h1>Orders</h1>

<p>
    <a asp-action="Create" class="btn btn-primary">Create New</a>
</p>
<table class="table">
    <thead>
        <tr>
            @if (this.User.IsInRole("Admin"))
            {
                <th>
                    @Html.DisplayNameFor(model => model.User.FullName)
                </th>
            }
            <th>
                @Html.DisplayNameFor(model => model.OrderDateLocal)          
            </th>
            <th>
                @Html.DisplayNameFor(model => model.DeliveryDate)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Lines)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Quantity)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Value)
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                @if (this.User.IsInRole("Admin"))
                {
                    <th>
                        @Html.DisplayFor(modelItem => item.User.FullName)
                    </th>
                }
                <td>
                    @Html.DisplayFor(modelItem => item.OrderDateLocal)                  
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DeliveryDate)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Lines)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Quantity)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Value)
                </td>
                <td>
                    <a asp-action="Deliver" asp-route-id="@item.Id" class="btn btn-info" id="btnDeliver">Deliver</a>
                    <a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger" id="btnDelete">Delete</a>
                </td>
            </tr>
        }
    </tbody>
</table>
