@model IEnumerable<IGrouping<string,BlogPost>>

@if (User.IsSignedIn()) {

<label>
<input type="checkbox" id="_cbv" checked/>Invisibles, posts privés</label>
    <script>
        $("#_cbv").change(function() {
            if (this.checked) {
                $("tr.hiddenpost").removeClass("hidden");
            } else {
                $("tr.hiddenpost").addClass("hidden");
            }
        });
        </script>
}

<table class="table">
@foreach (var group in Model) {
    var title = group.Key ?? "@";
    string secondclass="";
    var first = group.First();
    string ftrclass = (first.Visible) ? "visiblepost" : "hiddenpost";
   
  <tr><td colspan="3">
<a asp-action="Title" asp-route-id="@group.Key" >@title</a></td></tr> 
  @foreach (var item in group) {
      var trclass = (item.Visible)?"visiblepost":"hiddenpost";
      var trunked = item.Content?.Length > 256;
      <tr class="@trclass">
          <td><a asp-action="Details" asp-route-id="@item.Id" class="bloglink">
         <img src="@item.Photo" class="blogphoto"></a>
          </td>
          <td>
              <markdown summary="256">@item.Content</markdown>
              @if (trunked) { <a asp-action="Details" asp-route-id="@item.Id" class="bloglink">...</a> }
              <span style="font-size:x-small;">(@item.Author.UserName </span>,
              <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">
                  @if (await AuthorizationService.AuthorizeAsync(User, item, new ViewRequirement())) {
                  <li>
                      <a asp-action="Details" asp-route-id="@item.Id"  class="btn btn-lg">@SR["Details"]</a>
              </li>
                  }
              @if (await AuthorizationService.AuthorizeAsync(User, item, new EditRequirement())) {
              <li><a asp-action="Edit" asp-route-id="@item.Id" class="btn btn-default">@SR["Edit"]</a>
              </li>
              <li><a asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">@SR["Delete"]</a>
              </li>
              }
              </ul>
          </td>
      </tr>
  }
}
</table>


