@model IEnumerable<ResoursesManager.Models.Reservation>

@{
    ViewBag.Title = "Foglalások";
}

<h2>Foglalások</h2>


<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Begining)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.End)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.User)
        </th>
        <th></th>
    </tr>
    @{ var sortedmodel = Model.OrderBy(x => x.Begining).Where(x => x.End.CompareTo(DateTime.Now) > 0);}

    @foreach (var item in sortedmodel)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Begining)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.End)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.User)
            </td>
            <td>
                <div class="btn-group">
                    @Html.ActionLink("Részletek", "Details", "Reservations", new { id = item.Id }, new { @class = "btn btn-info" })
                    @if ((item.User == User.Identity.Name) || User.IsInRole("Admin"))
                    {
                        @Html.ActionLink("Módosítás", "Edit", "Reservations", new { id = item.Id }, new { @class = "btn btn-warning" })
                        @Html.ActionLink("Törlés", "Delete", "Reservations", new { id = item.Id }, new { @class = "btn btn-danger" })
                    }
                </div>
            </td>
        </tr>
    }

</table>
