Files
webzine/Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml
Florlan 909ed0e67b Feat: Commentaire
- création de la route commentaire dans program.cs
- création du CommentairesController
- création du CommentaireViewModel
- création de la vue index.cshtml des commentaire
- création du layout Admin
2026-03-05 13:07:50 +01:00

91 lines
2.6 KiB
Plaintext

@using Webzine.WebApplication.ViewModels
@using Webzine.Entity
@model CommentaireViewModel
@{
ViewData["Title"] = "Commentaires";
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<style>
.commentaires-container {
overflow-x: auto;
}
.commentaires-table {
width: 100%;
border-collapse: collapse;
margin-top: 1.5rem;
background: white;
}
.commentaires-table thead {
background: #ddd;
font-weight: bold;
}
.commentaires-table th, .commentaires-table td {
padding: 1rem;
border: 1px solid #ccc;
text-align: left;
}
.btn-delete {
color: #0066cc;
border: none;
background: none;
cursor: pointer;
font-size: 1.2rem;
}
.btn-delete:hover {
color: #ff4444;
}
</style>
<h1>Commentaires</h1>
<div class="commentaires-container">
<table class="commentaires-table">
<thead>
<tr>
<th>Titre</th>
<th>Auteur</th>
<th>Commentaire</th>
<th>Date de création</th>
<th style="text-align: center;">Actions</th>
</tr>
</thead>
<tbody>
@foreach (Webzine.Entity.Commentaire commentaire in Model.Commentaires)
{
<tr>
<td>
<!-- Titre est un objet, on affiche sa propriété Libelle -->
@(commentaire.Titre != null ? commentaire.Titre.Libelle : "Titre inconnu")
</td>
<td>
<!-- On utilise Auteur (et pas Nom) -->
@commentaire.Auteur
</td>
<td>
@commentaire.Contenu
</td>
<td>
@commentaire.DateCreation.ToString("dd/MM/yyyy HH:mm:ss")
</td>
<td style="text-align: center;">
<!-- On utilise IdCommentaire (et pas Id) -->
<form method="post" action="@Url.Action("Delete", new { id = commentaire.IdCommentaire })" style="display: inline;">
@Html.AntiForgeryToken()
<button type="submit" class="btn-delete" title="Supprimer">
<i class="fas fa-trash"></i>
</button>
</form>
</td>
</tr>
}
</tbody>
</table>
</div>