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

@@ -119,7 +119,7 @@ namespace Webzine.WebApplication.Controllers
this.titreRepository.IncrementNbLikes(titre);
}
return this.RedirectToAction("Details", new { id = model.IdTitre });
return this.RedirectToAction("Index", new { id = model.IdTitre });
}
/// <summary>
@@ -130,12 +130,6 @@ namespace Webzine.WebApplication.Controllers
[HttpPost]
public IActionResult Comment(TitreComment model)
{
if (!this.ModelState.IsValid)
{
this.logger.LogWarning("Echec de validation du modele de commentaire pour le titre ID {Id}.", model.IdTitre);
return this.RedirectToAction("Details", new { id = model.IdTitre });
}
var titre = this.titreRepository.Find(model.IdTitre);
if (titre == null)
@@ -156,7 +150,7 @@ namespace Webzine.WebApplication.Controllers
this.logger.LogInformation("Commentaire ajoute avec succes au titre ID {Id}.", model.IdTitre);
return this.RedirectToAction("Details", new { id = model.IdTitre });
return this.RedirectToAction("Index", new { id = model.IdTitre });
}
private static TitreStyleItem MapTitreItem(Titre titre)