@model IEnumerable<Yavsc.Models.Blog>
@{
    ViewData["Title"] = "Index";
    
}

<h2>Index</h2>
<p class="text-success">@ViewData["StatusMessage"]</p>
<p>
    <a asp-action="Create">@SR["Create a new article"]</a>
</p>

<table class="table">
    <tr>
        <th colspan="3">
            @SR[Html.DisplayNameFor(model => model.Title)]
        </th>
    </tr>
    
@foreach (var item in Model) {
    var trclass = (item.Visible)?"vpost":"ipost";

    <tr class="@trclass">
        <td><a asp-action="Details" asp-route-id="@item.Id">
       <img src="@item.Photo" >
           <markdown>@item.Title</markdown></a>
        </td>
        <td>
            <span style="font-size:x-small;"> @item.Author.UserName </span> <br>
            <span style="font-size:xx-small;">
            posté le @item.DateCreated.ToString("dddd d MMM yyyy à H:mm")
            @if ((item.DateModified - item.DateCreated).Minutes > 0){ 
                @:- Modifié le @item.DateModified.ToString("dddd d MMM yyyy à H:mm")
             }
            </span>
        </td>
        <td> 
            <ul class="actiongroup">
                <li><a asp-action="Details" asp-route-id="@item.Id">Details</a>
            </li>
            @if (await AuthorizationService.AuthorizeAsync(User, item, new EditRequirement())) {
            <li><a asp-action="Edit" asp-route-id="@item.Id">@SR["Edit"]</a>
            </li>
            <li><a asp-action="Delete" asp-route-id="@item.Id">@SR["Delete"]</a>
            </li>
            }
            </ul>
        </td>
    </tr>
}
</table>

<style>
    tr.vpost {
        background-color: #80A050;
        max-height: 3em;
    }
    tr.ipost {
        background-color: #303030;
        color: #b0b0b0;
        font-size: smaller;
        max-height: 3em;
    }
    tr.vpost a {
        font-weight: bold;
        color: white;
        text-shadow: 3px 3px 8px black; 
    }
    tr.ipost a {
        font-style: bold;
        color: #b0b0b0;
        text-shadow: 3px 3px 5px #505050; 
    }
    </style>


