@model IEnumerable<ResourcesManager.Models.Resource>

@{
    ViewBag.Title = "Erőforrások";
}

<h2>Erőforrások</h2>
<p>
    @if (User.IsInRole("Admin"))
    {
        <div class="btn-group">
            @Html.ActionLink("Új erőforrás felvétele", "Create", "", new { @class = "btn btn-primary" })
        </div>
    }
</p>

<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AssetTag)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Description)
        </th>
        <th></th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                <a href="@Url.Action("Details", new { id = item.Id })" class="resource-link">
                    <img src="@Url.Action("GetImage", "Resources", new { path = item.ImagePath } )" class="resource-img" />
                    <span class="resource-name">@item.Name</span>
                </a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.AssetTag)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Description)
            </td>
            <td class="text-right">
                @if (User.Identity.IsAuthenticated)
                {
                    <div class="btn-group">
                        @if (User.IsInRole("Admin"))
                        {
                            <a href="@Url.Action("Edit", new { id = item.Id })" class="btn btn-warning">
                                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                                
                            </a>
                            <a href="@Url.Action("Delete", new { id = item.Id })" class="btn btn-danger">
                                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
                                
                            </a>
                        }

                    </div>

                    @Html.ActionLink("Foglalás", "Create", "Reservations", new { ResourceId = item.Id }, new { @class = "btn btn-primary" })
                }

            </td>
        </tr>
    }

</table>
