Merge branch 'dev' into J1/refactor/conformité
This commit is contained in:
@@ -17,4 +17,5 @@
|
||||
06/03 :
|
||||
- Récupération des modifications depuis 'dev'
|
||||
- Ajout des redirections vers les pages 'Administration'
|
||||
- Adaptation du layout principal pour adaptation entre public et administration
|
||||
- Adaptation du layout principal pour adaptation entre public et administration
|
||||
- Ajout du Footer (sur toutes les pages)
|
||||
@@ -64,6 +64,36 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
// GET: Administration/Styles/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: Administration/Styles/Create
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Create(StyleCreateViewModel model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Nouveau style créé : {Libelle}", model.Libelle);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Erreur lors de la création du style");
|
||||
ModelState.AddModelError("", "Une erreur est survenue lors de la création.");
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GET: Administration/Styles/Delete/5
|
||||
public ActionResult Delete(int id)
|
||||
@@ -101,5 +131,50 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
// GET: Administration/Styles/Edit/5
|
||||
[HttpGet]
|
||||
public ActionResult Edit(int id)
|
||||
{
|
||||
// Recherche du style (simulation avec la liste _styles)
|
||||
var style = _styles.FirstOrDefault(s => s.IdStyle == id);
|
||||
|
||||
if (style == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
// Mapping vers le ViewModel
|
||||
var model = new StyleEditViewModel
|
||||
{
|
||||
IdStyle = style.IdStyle,
|
||||
Libelle = style.Libelle
|
||||
};
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// POST: Administration/Styles/Edit/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult Edit(int id, StyleEditViewModel model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Style {Id} mis à jour : {Libelle}", id, model.Libelle);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError(e, "Erreur lors de la modification du style {Id}", id);
|
||||
ModelState.AddModelError("", "Une erreur est survenue lors de la modification.");
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// <copyright file="StyleDeleteViewModel.cs" company="Webzine">
|
||||
// Copyright (c) Webzine. Tout droit réservé.
|
||||
// </copyright>
|
||||
|
||||
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// ViewModel pour la création d'un style en administration.
|
||||
/// </summary>
|
||||
|
||||
public class StyleCreateViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Obtient ou définit le libellé du style.
|
||||
/// </summary>
|
||||
|
||||
public string Libelle { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// <copyright file="StyleDeleteViewModel.cs" company="Webzine">
|
||||
// Copyright (c) Webzine. Tout droit réservé.
|
||||
// </copyright>
|
||||
|
||||
|
||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||
{
|
||||
/// <summary>
|
||||
/// ViewModel pour la modification d'un style en administration.
|
||||
/// </summary>
|
||||
|
||||
public class StyleEditViewModel
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Obtient ou définit le libellé du style.
|
||||
/// </summary>
|
||||
|
||||
public int IdStyle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Obtient ou définit le libellé du style.
|
||||
/// </summary>
|
||||
|
||||
public string Libelle { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Style.StyleCreateViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Créer un style";
|
||||
}
|
||||
|
||||
<div class="container mt-4">
|
||||
<h1 class="mb-3">Créer un style</h1>
|
||||
<hr />
|
||||
|
||||
<form asp-action="Create" method="post" class="mt-4">
|
||||
|
||||
@* Utilisation de d-flex pour aligner les éléments sur une ligne *@
|
||||
<div class="d-flex align-items-center">
|
||||
|
||||
@* Label *@
|
||||
<div class="me-3">
|
||||
<label asp-for="Libelle" class="col-form-label fw-bold">
|
||||
Libellé<span class="text-danger">*</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@* Input *@
|
||||
<div class="me-3">
|
||||
<input asp-for="Libelle" class="form-control" style="width: 250px;" />
|
||||
</div>
|
||||
|
||||
@* Bouton *@
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">Sauvegarder</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Zone d'erreur en dessous *@
|
||||
<div class="mt-2">
|
||||
<span asp-validation-for="Libelle" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="mt-4">
|
||||
<a asp-action="Index" class="btn-link">Retour à l'administration des styles</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Style.StyleEditViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Editer un style";
|
||||
}
|
||||
|
||||
<div class="container mt-4">
|
||||
<h1 class="mb-3">Editer un style</h1>
|
||||
<hr />
|
||||
|
||||
<form asp-action="Edit" method="post" class="mt-4">
|
||||
|
||||
@* Champ caché pour l'ID *@
|
||||
<input type="hidden" asp-for="IdStyle" />
|
||||
|
||||
@* Conteneur Flex pour alignement horizontal (Label - Input - Bouton) *@
|
||||
<div class="d-flex align-items-center">
|
||||
|
||||
@* Label *@
|
||||
<div class="me-3">
|
||||
<label asp-for="Libelle" class="col-form-label fw-bold">
|
||||
Libellé<span class="text-danger">*</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@* Input *@
|
||||
<div class="me-3">
|
||||
<input asp-for="Libelle" class="form-control" style="width: 250px;" />
|
||||
</div>
|
||||
|
||||
@* Bouton *@
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary">Sauvegarder</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* Zone d'erreur spécifique au champ *@
|
||||
<div class="mt-2">
|
||||
<span asp-validation-for="Libelle" class="text-danger"></span>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="mt-4">
|
||||
<a asp-action="Index" class="btn-link">Retour à l'administration des styles</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -4,22 +4,23 @@
|
||||
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) *@
|
||||
<div class="container mt-4">
|
||||
|
||||
<h1 class="mb-3">Styles</h1>
|
||||
<hr />
|
||||
|
||||
<div class="mb-3">
|
||||
<a asp-action="Create" class="btn btn-primary">
|
||||
<i class="fas fa-plus"></i> Nouveau Style
|
||||
<i class="fas fa-plus"></i> Ajouter un nouvel style
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover table-bordered">
|
||||
<thead class="table-light">
|
||||
<table class="table table-striped table-hover table-bordered table-sm">
|
||||
<thead class="table-active">
|
||||
<tr>
|
||||
<th scope="col" style="width: 10%;">#</th>
|
||||
<th scope="col">Libellé</th>
|
||||
<th scope="col" class="text-center" style="width: 15%;">Actions</th>
|
||||
<th scope="col" class="p-2">Libellé</th>
|
||||
<th scope="col" class="text-center p-2" style="width: 100px;">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -28,15 +29,14 @@
|
||||
@foreach (Webzine.Entity.Style style in Model.Styles)
|
||||
{
|
||||
<tr class="align-middle">
|
||||
<td>
|
||||
@style.IdStyle
|
||||
</td>
|
||||
<td>
|
||||
<td class="p-2">
|
||||
@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">
|
||||
<td class="text-center p-2">
|
||||
<a asp-action="Edit" asp-route-id="@style.IdStyle" class="text-primary me-2" title="Éditer">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<a asp-action="Delete" asp-route-id="@style.IdStyle" class="text-primary" title="Supprimer">
|
||||
<i class="fas fa-trash"></i>
|
||||
</a>
|
||||
</td>
|
||||
@@ -46,7 +46,7 @@
|
||||
else
|
||||
{
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">Aucun style disponible.</td>
|
||||
<td colspan="2" class="text-center p-2">Aucun style disponible.</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
13
Webzine.WebApplication/Views/Shared/_Footer.cshtml
Normal file
13
Webzine.WebApplication/Views/Shared/_Footer.cshtml
Normal file
@@ -0,0 +1,13 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
||||
<div class="container text-bg-light my-2 pb-0">
|
||||
<footer class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4">
|
||||
<div class="col-md-4 d-flex align-items-center">
|
||||
|
||||
<span class="mb-3 mb-md-0 ms-5 text-body-secondary">© ASP .NET Core - DIIAGE 2025 - 2026</span>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -15,7 +15,7 @@
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="container pb-0 mb-0">
|
||||
<partial name="_Header"/>
|
||||
<div class="row mt-5">
|
||||
<main class="col">
|
||||
@@ -26,6 +26,7 @@
|
||||
<partial name="_Sidebar" />
|
||||
}
|
||||
</div>
|
||||
<partial name="_Footer" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user