Merge pull request 'j1/feat/page_admin_artiste' (#72) from j1/feat/page_admin_artiste into dev
Reviewed-on: http://10.4.0.131/DI1-P4-E1/Webzine/pulls/72 Reviewed-by: Loic Masi <loic.masi@diiage.org>
This commit is contained in:
@@ -0,0 +1,64 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
|
using Webzine.Entity;
|
||||||
|
using Webzine.Entity.Fixtures;
|
||||||
|
using Webzine.WebApplication.Areas.Administration.ViewModels.Artiste;
|
||||||
|
using Webzine.WebApplication.Areas.Administration.ViewModels.Titre;
|
||||||
|
|
||||||
|
namespace Webzine.WebApplication.Areas.Administration.Controllers;
|
||||||
|
|
||||||
|
[Area("Administration")]
|
||||||
|
public class ArtisteController : Controller
|
||||||
|
{
|
||||||
|
// Injection du logger via le constructeur
|
||||||
|
private readonly ILogger<ArtisteController> _logger;
|
||||||
|
|
||||||
|
public ArtisteController(ILogger<ArtisteController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
this._logger.LogDebug(1, "initialisation du ArtisteController d'administration");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Affiche la liste des artistes. Pour l'instant, les artistes sont générés à partir de noms prédéfinis via la méthode SeedArtisteByName de la classe ArtisteFactory.
|
||||||
|
/// Chaque artiste est ensuite ajouté à une liste d'artistes qui est passée à la vue via un objet GroupeArtisteViewModel.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
var nomsArtistes = new List<string> { "The Beatles", "Théa", "Thédora", "Ricchi E Poveri", "Bad Bunny", "horsegiirL" };
|
||||||
|
List<Artiste> artistes = new List<Artiste>();
|
||||||
|
|
||||||
|
foreach (var nom in nomsArtistes)
|
||||||
|
{
|
||||||
|
Artiste artiste = ArtisteFactory.SeedArtisteByName(nom);
|
||||||
|
artistes.Add(artiste);
|
||||||
|
}
|
||||||
|
|
||||||
|
GroupeArtisteViewModel groupeArtisteModel = new GroupeArtisteViewModel
|
||||||
|
{
|
||||||
|
Artistes = artistes
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(groupeArtisteModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renvoie à la page modifier un artiste.
|
||||||
|
/// Méthode vide pour le moment.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IActionResult Edit()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renvoie à la page supprimer un artiste.
|
||||||
|
/// Méthode vide pour le moment.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IActionResult Delete()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Artiste
|
||||||
|
{
|
||||||
|
using Webzine.Entity;
|
||||||
|
/// <summary>
|
||||||
|
/// ViewModel pour afficher un groupe d'artiste.
|
||||||
|
/// </summary>
|
||||||
|
public class GroupeArtisteViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Liste d'artistes.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<Artiste> Artistes { get; set; } = new List<Artiste>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.GroupeArtisteViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Artiste";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
<h1 class="mb-4">Artiste</h1>
|
||||||
|
<hr />
|
||||||
|
<a asp-action="" class="btn btn-primary mb-3">
|
||||||
|
<i class="fa fa-plus"></i> Ajouter un nouvel titre
|
||||||
|
</a>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-hover table-bordered">
|
||||||
|
<thead class="table-active">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">Nom de l'artiste</th>
|
||||||
|
<th scope="col" class="text-center">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@* On groupe les artistes par nom *@
|
||||||
|
@{
|
||||||
|
var artistes = Model.Artistes
|
||||||
|
.OrderBy(t => t.Nom); // Trie les artistes par ordre alphabétique
|
||||||
|
}
|
||||||
|
|
||||||
|
@foreach (var artiste in artistes)
|
||||||
|
{
|
||||||
|
<tr class="align-middle">
|
||||||
|
<td class="col-10">
|
||||||
|
@artiste.Nom
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
|
||||||
|
<a asp-action="Edit" asp-route-id="@artiste.IdArtiste"
|
||||||
|
class="btn btn-sm btn-outline-primary">
|
||||||
|
<i class="fa fa-pen"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a asp-action="Delete" asp-route-id="@artiste.IdArtiste"
|
||||||
|
class="btn btn-sm btn-outline-danger">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Webzine.Entity;
|
using Webzine.Entity;
|
||||||
|
|
||||||
namespace Webzine.WebApplication.ViewModels
|
namespace Webzine.WebApplication.ViewModels.Artiste
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ViewModel pour afficher les détails d'un artiste, incluant les informations de l'artiste et la liste de ses titres.
|
/// ViewModel pour afficher les détails d'un artiste, incluant les informations de l'artiste et la liste de ses titres.
|
||||||
Reference in New Issue
Block a user