Merge branch 'dev' into j1/feat/page_contact
This commit is contained in:
@@ -5,9 +5,18 @@ namespace Webzine.WebApplication.Controllers
|
||||
{
|
||||
public class AccueilController : Microsoft.AspNetCore.Mvc.Controller
|
||||
{
|
||||
// Injection du logger via le constructeur
|
||||
private readonly ILogger<AccueilController> _logger;
|
||||
|
||||
public AccueilController(ILogger<AccueilController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
// GET: AccueilController
|
||||
public ActionResult Index()
|
||||
{
|
||||
_logger.LogInformation("Arrivée sur la page d'accueil");
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
54
Webzine.WebApplication/Controllers/ArtisteController.cs
Normal file
54
Webzine.WebApplication/Controllers/ArtisteController.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Webzine.Entity.Fixtures;
|
||||
using Webzine.WebApplication.ViewModels;
|
||||
|
||||
namespace Webzine.WebApplication.Controllers
|
||||
{
|
||||
public class ArtisteController : Controller
|
||||
{
|
||||
// Injection du logger via le constructeur
|
||||
private readonly ILogger<ArtisteController> _logger;
|
||||
|
||||
public ArtisteController(ILogger<ArtisteController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prend en paramètre le nom de l'artiste (ex: "fatal-bazooka"), utilise la factory pour trouver l'artiste correspondant, et affiche sa page dédiée.
|
||||
/// </summary>
|
||||
/// <param name="nom"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("/artiste/{nom}")]
|
||||
public IActionResult Index(string nom)
|
||||
{
|
||||
_logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom);
|
||||
|
||||
if (string.IsNullOrEmpty(nom)) return RedirectToAction("Index", "Accueil");
|
||||
|
||||
// On transforme "fatal-bazooka" en "Fatal Bazooka" pour la factory
|
||||
string nomPropre = System.Globalization.CultureInfo.CurrentCulture.TextInfo
|
||||
.ToTitleCase(nom.Replace("-", " "));
|
||||
|
||||
// On appelle la factory pour obtenir l'artiste unique
|
||||
var artiste = ArtisteFactory.SeedArtisteByName(nomPropre);
|
||||
|
||||
if (artiste == null)
|
||||
{
|
||||
_logger.LogWarning("Artiste non trouvé pour le nom : {NomArtiste}", nomPropre);
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
_logger.LogInformation("Artiste trouvé : {NomArtiste}", nom);
|
||||
|
||||
// On remplit le ViewModel
|
||||
var viewModel = new ArtisteModel
|
||||
{
|
||||
Artiste = artiste,
|
||||
Titres = artiste.Titres
|
||||
};
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Webzine.WebApplication/ViewModels/ArtisteModel.cs
Normal file
17
Webzine.WebApplication/ViewModels/ArtisteModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Webzine.Entity;
|
||||
|
||||
namespace Webzine.WebApplication.ViewModels
|
||||
{
|
||||
public class ArtisteModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Artiste dont on affiche les détails.
|
||||
/// </summary>
|
||||
public Artiste Artiste { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Liste des titres de l'artiste.
|
||||
/// </summary>
|
||||
public List<Titre> Titres { get; set; }
|
||||
}
|
||||
}
|
||||
70
Webzine.WebApplication/Views/Artiste/Index.cshtml
Normal file
70
Webzine.WebApplication/Views/Artiste/Index.cshtml
Normal file
@@ -0,0 +1,70 @@
|
||||
@model Webzine.WebApplication.ViewModels.ArtisteModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Artiste";
|
||||
}
|
||||
|
||||
|
||||
<div class="container">
|
||||
<h1>@Model.Artiste.Nom</h1>
|
||||
|
||||
<hr class="mb-5" />
|
||||
|
||||
<p class="lead">@Model.Artiste.Biographie</p>
|
||||
|
||||
<h2 class="mt-5 mb-4">Albums</h2>
|
||||
<hr class="mb-5" />
|
||||
|
||||
@* On groupe les titres par nom d'album *@
|
||||
@{
|
||||
var albumsGroupes = Model.Titres
|
||||
.OrderBy(t => t.Libelle) // Trie les titres par ordre alphabétique au sein de chaque groupe futur
|
||||
.GroupBy(t => t.Album) // Groupe par nom d'album
|
||||
.OrderBy(g => g.Key); // Trie les albums par ordre alphabétique (la clé du groupe)
|
||||
}
|
||||
|
||||
@foreach (var groupe in albumsGroupes)
|
||||
{
|
||||
// On récupère le premier titre du groupe pour afficher l'image de l'album
|
||||
var premierTitre = groupe.First();
|
||||
|
||||
<div class="row mb-5 align-items-start">
|
||||
<div class="col-md-3 mb-3">
|
||||
<img src="@premierTitre.UrlJaquette"
|
||||
class="img-fluid shadow-sm rounded border"
|
||||
alt="Pochette de @groupe.Key" />
|
||||
</div>
|
||||
|
||||
<div class="col-md-9">
|
||||
<h3 class="h4 pb-2">@groupe.Key</h3>
|
||||
|
||||
<table class="table table-hover table-sm mt-3">
|
||||
<thead class="text-muted">
|
||||
<tr>
|
||||
<th style="width: 80px">Durée</th>
|
||||
<th>Titre</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var titre in groupe)
|
||||
{
|
||||
// Conversion des secondes en format MM:SS
|
||||
var minutes = titre.Duree / 60;
|
||||
var secondes = titre.Duree % 60;
|
||||
var dureeFormatee = $"{minutes}:{secondes:D2}";
|
||||
|
||||
<tr>
|
||||
<td class="text-secondary font-monospace">@dureeFormatee</td>
|
||||
<td>
|
||||
<span class="text-primary fw-bold" style="cursor:pointer">
|
||||
@titre.Libelle
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -7,4 +7,7 @@
|
||||
<View_SelectedScaffolderID>RazorViewEmptyScaffolder</View_SelectedScaffolderID>
|
||||
<View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user