#162 : Patch bug lors de retour sur une page "Delete" après la suppression d'un élément. Redirection sur la page "Index" en cas de retour en arrière de la part d'un utilisateur.
This commit is contained in:
@@ -83,8 +83,8 @@ namespace Webzine.Repository
|
||||
try
|
||||
{
|
||||
Artiste artiste = this.context.Artistes
|
||||
.Include(a => a.Titres)
|
||||
.First(a => a.IdArtiste == id);
|
||||
.Include(a => a.Titres)
|
||||
.FirstOrDefault(a => a.IdArtiste == id);
|
||||
return artiste;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -262,7 +262,6 @@ public class DbTitreRepository : ITitreRepository
|
||||
try
|
||||
{
|
||||
this.logger.LogDebug("Recherche du titre avec l'ID: {IdTitre}", idTitre);
|
||||
this.logger.LogDebug("Préparation de la requête avec les inclusions Artiste, Styles et Commentaires");
|
||||
|
||||
var titre = this.context.Titres
|
||||
.Include(t => t.Artiste)
|
||||
@@ -270,7 +269,6 @@ public class DbTitreRepository : ITitreRepository
|
||||
.Include(t => t.Commentaires)
|
||||
.FirstOrDefault(t => t.IdTitre == idTitre);
|
||||
|
||||
this.logger.LogDebug("Titre trouvé: {Libelle}", titre.Libelle);
|
||||
return titre;
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
|
||||
@@ -87,6 +87,12 @@ public class ArtisteController : Controller
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
var artiste = this.artisteRepository.Find(id);
|
||||
|
||||
if (artiste == null)
|
||||
{
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
var model = new AdminArtisteForm
|
||||
{
|
||||
Id = id,
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers
|
||||
{
|
||||
var commentaire = this.commentaireRepository.Find(id);
|
||||
|
||||
if (commentaire == null)
|
||||
{
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
var model = new CommentaireDeleteViewModel
|
||||
{
|
||||
IdCommentaire = commentaire.IdCommentaire,
|
||||
|
||||
@@ -130,6 +130,11 @@ public class TitreController : Controller
|
||||
{
|
||||
var titre = this.titreRepository.Find(id);
|
||||
|
||||
if (titre == null)
|
||||
{
|
||||
return this.RedirectToAction("Index");
|
||||
}
|
||||
|
||||
var model = new AdminTitreDelete
|
||||
{
|
||||
Id = titre.IdTitre,
|
||||
|
||||
Reference in New Issue
Block a user