J1: Admin/Style #47 #60 #28 #61:

- Création StyleViewModel
- Création StylesController
- Création de index.cshtml et delete.cshtml
This commit is contained in:
b.nodon
2026-03-06 11:02:54 +01:00
parent 39ed42405b
commit a29007265b
6 changed files with 230 additions and 1 deletions

View File

@@ -0,0 +1,43 @@
@model Webzine.WebApplication.Areas.Administration.ViewModels.Style.StyleDeleteViewModel
@{
ViewData["Title"] = "Supprimer un style";
}
<div class="container mt-4">
<h1 class="mb-3">Supprimer un style</h1>
<hr />
<p class="mb-4">
Êtes-vous sûr de vouloir supprimer le style suivant ?
</p>
<div class="mb-4">
@* On affiche le Libellé en gros *@
<h4>@Model.Libelle</h4>
@* On affiche l'ID discrètement en dessous *@
<div class="text-muted">
Identifiant technique : @Model.IdStyle
</div>
</div>
<form asp-action="Delete" method="post">
@* Champ caché indispensable pour transmettre l'ID au contrôleur en POST *@
<input type="hidden" asp-for="IdStyle" />
<button type="submit" class="btn btn-danger">
Supprimer
</button>
</form>
<br />
<br />
<a asp-action="Index"
class="btn-link">
Retour à l'administration des styles
</a>
</div>

View File

@@ -0,0 +1,55 @@
@model Webzine.WebApplication.Areas.Administration.ViewModels.Style.StyleViewModel
@{
ViewData["Title"] = "Styles";
}
<div class="justify-content-center m-5">
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Gestion des Styles</h1>
@* Lien vers la création (optionnel si vous n'avez pas encore fait l'action Create) *@
<a asp-action="Create" class="btn btn-primary">
<i class="fas fa-plus"></i> Nouveau Style
</a>
</div>
<div class="table-responsive">
<table class="table table-striped table-hover table-bordered">
<thead class="table-light">
<tr>
<th scope="col" style="width: 10%;">#</th>
<th scope="col">Libellé</th>
<th scope="col" class="text-center" style="width: 15%;">Actions</th>
</tr>
</thead>
<tbody>
@if (Model.Styles != null && Model.Styles.Any())
{
@foreach (Webzine.Entity.Style style in Model.Styles)
{
<tr class="align-middle">
<td>
@style.IdStyle
</td>
<td>
@style.Libelle
</td>
<td class="text-center">
@* Bouton Supprimer (correspond à votre action Delete) *@
<a asp-action="Delete" asp-route-id="@style.IdStyle" class="d-inline btn btn-link text-main" title="Supprimer">
<i class="fas fa-trash"></i>
</a>
</td>
</tr>
}
}
else
{
<tr>
<td colspan="3" class="text-center">Aucun style disponible.</td>
</tr>
}
</tbody>
</table>
</div>
</div>