diff --git a/Webzine.Repository/DbArtisteRepository.cs b/Webzine.Repository/DbArtisteRepository.cs index 5f298a3..b87a6b3 100644 --- a/Webzine.Repository/DbArtisteRepository.cs +++ b/Webzine.Repository/DbArtisteRepository.cs @@ -103,12 +103,6 @@ namespace Webzine.Repository .Include(a => a.Titres) .FirstOrDefault(a => a.Nom == nom); - if (artiste == null) - { - this.logger.LogWarning("Pas d'artiste au nom {Nom}", nom); - artiste = new Artiste(); - } - return artiste; } catch (Exception ex) diff --git a/Webzine.WebApplication/Controllers/ArtisteController.cs b/Webzine.WebApplication/Controllers/ArtisteController.cs index 6f395d2..74165a7 100644 --- a/Webzine.WebApplication/Controllers/ArtisteController.cs +++ b/Webzine.WebApplication/Controllers/ArtisteController.cs @@ -36,7 +36,7 @@ if (string.IsNullOrEmpty(nom)) { this.logger.LogWarning("Nom de l'artiste manquant dans la requête."); - return RedirectToAction("Index"); + return this.RedirectToAction("Index", "Accueil"); } // On transforme "fatal-bazooka" en "Fatal Bazooka" pour la factory @@ -46,26 +46,23 @@ // On appelle la factory pour obtenir l'artiste unique var artiste = this._artisteRepository.FindByName(nomPropre); + // Check if artiste was found if (artiste == null) { - this.logger.LogWarning("Artiste non trouvé pour le nom : {NomArtiste}", nomPropre); - return RedirectToAction("Index"); + this.logger.LogWarning("Artiste non trouvé avec le nom : {NomArtiste}", nomPropre); + return this.RedirectToAction("Index", "Accueil"); } + var viewModel = new ArtisteDetailsViewModel { IdArtiste = artiste.IdArtiste, Nom = artiste.Nom, Biographie = artiste.Biographie, - // On effectue le groupement ici une bonne fois pour toutes - AlbumsGroupes = artiste.Titres - .OrderBy(t => t.Libelle) - .GroupBy(t => t.Album) - .OrderBy(g => g.Key), + AlbumsGroupes = artiste.Titres.GroupBy(t => t.Album), }; this.logger.LogInformation("Artiste trouvé : {NomArtiste}", nom); - - return View(viewModel); + return this.View(viewModel); } } }