refactor: simplifier les actions du contrôleur en supprimant les contrôles ModelState redondants et en améliorant la récupération des données

This commit is contained in:
mirage
2026-04-02 15:57:52 +02:00
parent 6ccb8173ee
commit 8acafbfe49
16 changed files with 158 additions and 61 deletions

View File

@@ -63,11 +63,6 @@ public class StyleController : Controller
[HttpPost]
public IActionResult Create(StyleCreateViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
var style = new Style
{
Libelle = model.Libelle,
@@ -124,7 +119,6 @@ public class StyleController : Controller
/// </summary>
/// <param name="id">L'identifiant du style a editer.</param>
/// <returns>La vue d'edition ou une redirection vers l'index si le style n'existe pas.</returns>
[HttpGet]
public IActionResult Edit(int id)
{
var style = this.styleRepository.Find(id);
@@ -151,11 +145,6 @@ public class StyleController : Controller
[HttpPost]
public IActionResult Edit(StyleEditViewModel model)
{
if (!this.ModelState.IsValid)
{
return this.View(model);
}
var style = this.styleRepository.Find(model.IdStyle);
if (style == null)
{