@model IEnumerable<ResourcesManager.Models.Resource>

@{
    ViewBag.Title = "Felíratkozás";
}

<h2>Felíratkozás</h2>
<p>
    @if (User.Identity.IsAuthenticated)
    {
        <div class="btn-group">
            @Html.ActionLink("Leíratkozás az összesről", "UnFollowAll", "", new { @class = "btn btn-default" })
            @Html.ActionLink("Felíratkozás az összesre", "FollowAll", "", new { @class = "btn btn-success" })
        </div>

    }
</p>

<table class="table table-responsive table-striped">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AssetTag)
        </th>
        <th></th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                <img src="@Url.Action("GetImage", "Resources", new { path = item.ImagePath } )" class="subscribe-img" />
                <a href="@Url.Action("Details","Resources", new { id = item.Id })" class="resource-link">
                <span class="subscribe-name">@item.Name</span>
                </a>
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.AssetTag)
            </td>
            <td class="text-right">
                @if (User.Identity.IsAuthenticated)
                {
                    <div class="btn-group">
                        @{
                            var user = User.Identity.Name;
                            if (item.Users.Any(e => e.UserName == user))
                            {
                                @Html.ActionLink("Leíratkozás", "Unfollow", new { ResourceId = item.Id }, new { @class = "btn btn-default" })
                            }
                            else
                            {
                                @Html.ActionLink("Felíratkozás", "Follow", new { ResourceId = item.Id }, new { @class = "btn btn-success" })
                            }
                        }
                    </div>
                }
            </td>
        </tr>
    }
</table>
