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

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Wierszówki
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%  if (ViewData.Model.naglowek != null){  %>
            <h2><%= ViewData.Model.naglowek %></h2>
    <%  } %>        
    <table>
        <tr>
            <th></th>
            <th></th>
            <th>Miesiąc</th>
            <th>Autor</th>
            <th>Wydanie</th>
            <th>Typ</th>
            <th>Tytuł</th>
            <th>Opis</th>
            <th>Wycena</th>
            <th>Bonus</th>
            <th>Kto utworzył</th>
            <th>Ostatnia aktualizacja</th>
        </tr>
    
    <% int number = 0;
        foreach (var item in ViewData.Model.magazine) {
            number += 1;         
    %>    
        <tr>
            <td>
                                   <%
                     if (ViewData.Model.info.powrot == "1")
                     {
                    %>
                        <%= Html.ActionLink("Edycja", "Edit", "MagazineItem", new { id = item.Id, powrot = "1", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%>
                    <%
                     }
                     else if (ViewData.Model.info.powrot == "2")
                     {
                    %>
                        <%= Html.ActionLink("Edycja", "Edit", "MagazineItem", new { id = item.Id, powrot = "2", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%>
                    <%
                     }
                    %>
            </td>
            <td>
                <%
                if (ViewData.Model.info.powrot == "1")
                {
                %>
                    <%= Html.ActionLink("Usuń", "Delete", "MagazineItem", new { id = item.Id, powrot="1", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%> 
                <%
                }
                else if (ViewData.Model.info.powrot == "2")
                {
                %>
                    <%= Html.ActionLink("Usuń", "Delete", "MagazineItem", new { id = item.Id, powrot="2", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%>
                <%
                }
                %>                
            </td>
            <td>
                <%= Html.Encode(item.Date.ToString("yyyy-MM")) %>
            </td>
            <td width="85px">
                <%= Html.Encode(item.Author.FullName) %>
            </td>
            <td width="62px">
                <%= Html.Encode(item.Issue.Identifier)%>
            </td>
            <td width="48px">
                <%= Html.Encode(item.ItemType.Name) %>
            </td>
            <td width="150px">
                <%= Html.Encode(item.Caption) %>
            </td>
            <td width="140px"> 
                <%= Html.Encode(item.Description) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:F}", item.Price)) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:F}", item.Bonus)) %>
            </td>
            <td>
                <%= Html.Encode(item.CreatedByUser.Login) %>
            </td>
            <td width="140px">
                <%= Html.Encode(item.UpdatedOn) %>
            </td>
        </tr>
    
    <% } %>

    </table>
    <p>
        <%
            if (ViewData.Model.info.powrot == "1")
            {
        %>
            <%= Html.ActionLink("Powrót", "Index", "Home")%> |
        <%
            }
            else
            {
        %>
            <%= Html.ActionLink("Powrót", "Index", "Report")%> |
        <%
            } 
        %>    
        Liczba wierszówek: <%=number%>
    </p>

</asp:Content>

