<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<FotbalPortal.Models.UserProfile>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Uživatelé
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2>Uživatelé</h2>

<table>
    <tr>
        <th>
            Jméno
        </th>
        <th></th>
    </tr>

<% foreach (var item in Model) { %>
    <tr>
        <td>
            <%: Html.DisplayFor(modelItem => item.UserName) %>
        </td>
        <td>
            <% 
               var exists = false;
               foreach (var friendId in ViewBag.friends)
               {
                   if (friendId == item.UserId)
                   {
                       exists = true;
                   }
           
               }
       
               if (!exists) { %>
                <%: Html.ActionLink("Přátelství", "Friendship", new { id=item.UserId }) %>
            <% } else { %>
                <%: Html.ActionLink("Odebrat z přátel", "Unfriendship", new { friendId=item.UserId }, new{@onclick="return confirm('Opravdu odebrat z přátel?')"} ) %>
            <% } %>
        </td>
    </tr>
<% } %>

</table>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptsSection" runat="server">
</asp:Content>
