Merge pull request 'feat/admin_artiste_crud_pages' (#78) from feat/admin_artiste_crud_pages into dev
Reviewed-on: http://10.4.0.131/DI1-P4-E1/Webzine/pulls/78
This commit is contained in:
@@ -12,53 +12,86 @@ public class ArtisteController : Controller
|
|||||||
{
|
{
|
||||||
// Injection du logger via le constructeur
|
// Injection du logger via le constructeur
|
||||||
private readonly ILogger<ArtisteController> _logger;
|
private readonly ILogger<ArtisteController> _logger;
|
||||||
|
private readonly List<Artiste> _artistes;
|
||||||
|
|
||||||
|
|
||||||
public ArtisteController(ILogger<ArtisteController> logger)
|
public ArtisteController(ILogger<ArtisteController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
this._logger.LogDebug(1, "initialisation du ArtisteController d'administration");
|
this._logger.LogDebug(1, "initialisation du ArtisteController d'administration");
|
||||||
|
var factory = new DataFactory();
|
||||||
|
|
||||||
|
_artistes = factory.GenerateArtists(10);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <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.
|
/// 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.
|
/// Chaque artiste est ensuite ajouté à une liste d'artistes qui est passée à la vue via un objet GroupeArtisteViewModel.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns>Redirection.</returns>
|
||||||
public IActionResult Index()
|
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)
|
var _artistes_ordre = _artistes.OrderBy(t => t.Nom).ToList();
|
||||||
{
|
|
||||||
Artiste artiste = ArtisteFactory.SeedArtisteByName(nom);
|
_logger.LogInformation("Initialisation du contrôleur TitreController pour l'Administration.");
|
||||||
artistes.Add(artiste);
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupeArtisteViewModel groupeArtisteModel = new GroupeArtisteViewModel
|
GroupeArtisteViewModel groupeArtisteModel = new GroupeArtisteViewModel
|
||||||
{
|
{
|
||||||
Artistes = artistes
|
Artistes = _artistes_ordre
|
||||||
};
|
};
|
||||||
|
|
||||||
return View(groupeArtisteModel);
|
return View(groupeArtisteModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renvoie à la page modifier un artiste.
|
/// Renvoie à la page pour créer un artiste.
|
||||||
/// Méthode vide pour le moment.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns>Redirection.</returns>
|
||||||
public IActionResult Edit()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
return View();
|
var model = new AdminArtisteForm
|
||||||
|
{
|
||||||
|
Id = 0,
|
||||||
|
Nom = string.Empty,
|
||||||
|
Biographie = string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renvoie à la page modifier un artiste.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">L'identifiant de l'artiste à modifier. </param>
|
||||||
|
/// <returns>Redirection.</returns>
|
||||||
|
public IActionResult Edit(int id)
|
||||||
|
{
|
||||||
|
var artiste = _artistes.First(t => t.IdArtiste == id);
|
||||||
|
|
||||||
|
var model = new AdminArtisteForm
|
||||||
|
{
|
||||||
|
Id = artiste.IdArtiste,
|
||||||
|
Nom = artiste.Nom,
|
||||||
|
Biographie = artiste.Biographie
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Renvoie à la page supprimer un artiste.
|
/// Renvoie à la page supprimer un artiste.
|
||||||
/// Méthode vide pour le moment.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <param name="id">L'identifiant de l'artiste à supprimer. </param>
|
||||||
public IActionResult Delete()
|
/// <returns>Redirection.></returns>
|
||||||
|
public IActionResult Delete(int id)
|
||||||
{
|
{
|
||||||
return View();
|
var artiste = _artistes.First(t => t.IdArtiste == id);
|
||||||
|
var model = new AdminArtisteForm
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Nom = artiste.Nom,
|
||||||
|
Biographie = artiste.Biographie
|
||||||
|
};
|
||||||
|
return View(model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,21 +9,21 @@ using Webzine.WebApplication.Areas.Administration.ViewModels.Style;
|
|||||||
namespace Webzine.WebApplication.Areas.Administration.Controllers
|
namespace Webzine.WebApplication.Areas.Administration.Controllers
|
||||||
{
|
{
|
||||||
[Area("Administration")]
|
[Area("Administration")]
|
||||||
public class StylesController : Controller
|
public class StyleController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<StylesController> _logger;
|
private readonly ILogger<StyleController> _logger;
|
||||||
private readonly List<Style> _styles;
|
private readonly List<Style> _styles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialise une nouvelle instance du <see cref="StylesController"/>.
|
/// Initialise une nouvelle instance du <see cref="StyleController"/>.
|
||||||
/// Les données sont générées dynamiquement via <see cref="DataFactory"/>.
|
/// Les données sont générées dynamiquement via <see cref="DataFactory"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger">Service de journalisation injecté.</param>
|
/// <param name="logger">Service de journalisation injecté.</param>
|
||||||
public StylesController(ILogger<StylesController> logger)
|
public StyleController(ILogger<StyleController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
_logger.LogInformation("Initialisation du contrôleur StylesController.");
|
_logger.LogInformation("Initialisation du contrôleur StyleController.");
|
||||||
|
|
||||||
var factory = new DataFactory();
|
var factory = new DataFactory();
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ public class TitreController : Controller
|
|||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
_logger.LogInformation("Initialisation du contrôleur TitreController.");
|
_logger.LogInformation("Initialisation du contrôleur TitreController pour l'Administration.");
|
||||||
|
|
||||||
var factory = new DataFactory();
|
var factory = new DataFactory();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Artiste
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ViewModel pour la création et la modification d'un artiste dans l'administration.
|
||||||
|
/// </summary>
|
||||||
|
public class AdminArtisteForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Définit l'identifiant de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Définit le nom de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
public string Nom { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Définit la biographie de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
public string Biographie { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.AdminArtisteForm
|
||||||
|
|
||||||
|
<h1>Créer un artiste</h1>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<form asp-action="Create" method="post">
|
||||||
|
|
||||||
|
<partial name="_Form" />
|
||||||
|
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.AdminArtisteForm
|
||||||
|
|
||||||
|
<div class="container mt-4">
|
||||||
|
|
||||||
|
<h1 class="mb-3">Supprimer un artiste</h1>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Etes-vous sûr de vouloir supprimer l'artiste
|
||||||
|
"@Model.Nom" ?
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<form asp-action="Delete" method="post">
|
||||||
|
|
||||||
|
<input type="hidden" asp-for="Id" />
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-danger">
|
||||||
|
Supprimer
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
|
||||||
|
<a asp-action="Index">
|
||||||
|
Retour à l'administration des artistes
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.AdminArtisteForm
|
||||||
|
|
||||||
|
<h1>Editer un artiste</h1>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<form asp-action="Edit" method="post">
|
||||||
|
|
||||||
|
<input type="hidden" asp-for="Id"/>
|
||||||
|
|
||||||
|
<partial name="_Form" />
|
||||||
|
|
||||||
|
</form>
|
||||||
@@ -8,39 +8,34 @@
|
|||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<h1 class="mb-4">Artiste</h1>
|
<h1 class="mb-4">Artiste</h1>
|
||||||
<hr />
|
<hr />
|
||||||
<a asp-action="" class="btn btn-primary mb-3">
|
<a asp-action="Create" class="btn btn-primary mb-3">
|
||||||
<i class="fa fa-plus"></i> Ajouter un nouvel titre
|
<i class="fa fa-plus"></i> Ajouter un nouvel artiste
|
||||||
</a>
|
</a>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-bordered">
|
<table class="table table-striped table-hover table-bordered table-sm">
|
||||||
<thead class="table-active">
|
<thead class="table-active">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Nom de l'artiste</th>
|
<th scope="col" class="p-2">Nom</th>
|
||||||
<th scope="col" class="text-center">Actions</th>
|
<th scope="col" class="text-center p-2" style="width: 100px;">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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)
|
@foreach (var artiste in Model.Artistes)
|
||||||
{
|
{
|
||||||
<tr class="align-middle">
|
<tr class="align-middle">
|
||||||
<td class="col-10">
|
<td class="p-2">
|
||||||
@artiste.Nom
|
@artiste.Nom
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center p-2">
|
||||||
|
|
||||||
<a asp-action="Edit" asp-route-id="@artiste.IdArtiste"
|
<a asp-action="Edit" asp-route-id="@artiste.IdArtiste"
|
||||||
class="btn btn-sm text-primary">
|
class="text-primary">
|
||||||
<i class="fa fa-pen"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a asp-action="Delete" asp-route-id="@artiste.IdArtiste"
|
<a asp-action="Delete" asp-route-id="@artiste.IdArtiste"
|
||||||
class="btn btn-sm text-primary">
|
class="text-primary">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.AdminArtisteForm
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<!-- ARTISTE -->
|
||||||
|
<div class="row mb-3 align-items-center">
|
||||||
|
<label class="col-md-3 col-form-label">Nom de l'artiste<span class="text-danger">*</span></label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<input asp-for="Nom" class="form-control" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- BIOGRAPHIE -->
|
||||||
|
<div class="row mb-3 align-items-center">
|
||||||
|
<label class="col-md-3 col-form-label">Biographie<span class="text-danger">*</span></label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<input asp-for="Biographie" class="form-control"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- BOUTONS -->
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-md-9 offset-md-3">
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary me-2">
|
||||||
|
Sauvegarder
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<a asp-action="Index"
|
||||||
|
class="btn text-primary">
|
||||||
|
Retour à l'administration des artistes
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
@@ -5,18 +5,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<div class="justify-content-center m-5">
|
<div class="container mt-4">
|
||||||
<h1 class="mb-4">Commentaires</h1>
|
<h1 class="mb-4">Commentaires</h1>
|
||||||
|
<hr />
|
||||||
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover table-bordered">
|
<table class="table table-striped table-hover table-bordered">
|
||||||
<thead class="table-light">
|
<thead class="table-active">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Titre</th>
|
<th scope="col">Titre</th>
|
||||||
<th scope="col">Auteur</th>
|
<th scope="col">Auteur</th>
|
||||||
<th scope="col">Commentaire</th>
|
<th scope="col">Commentaire</th>
|
||||||
<th scope="col">Date de création</th>
|
<th scope="col">Date de création</th>
|
||||||
<th scope="col" class="text-center">Actions</th>
|
<th scope="col" class="text-center p-2" style="width: 100px" ;>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -9,53 +9,55 @@
|
|||||||
<h1 class="mb-3">Titres</h1>
|
<h1 class="mb-3">Titres</h1>
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<a asp-action="" class="btn btn-primary mb-3">
|
<a asp-action="Create" class="btn btn-primary mb-3">
|
||||||
<i class="fa fa-plus"></i> Ajouter un nouvel titre
|
<i class="fa fa-plus"></i> Ajouter un nouveau titre
|
||||||
</a>
|
</a>
|
||||||
|
<div class="table-responsive">
|
||||||
|
|
||||||
<table class="table table-striped table-bordered align-middle">
|
<table class="table table-striped table-hover table-bordered">
|
||||||
<thead class="table-light">
|
<thead class="table-active">
|
||||||
<tr>
|
|
||||||
<th>Artiste</th>
|
|
||||||
<th>Titre</th>
|
|
||||||
<th>Durée</th>
|
|
||||||
<th>Date de sortie</th>
|
|
||||||
<th class="text-center"><i class="fa fa-eye"></i></th>
|
|
||||||
<th class="text-center"><i class="fa fa-thumbs-up"></i></th>
|
|
||||||
<th class="text-center"><i class="fa fa-comments"></i></th>
|
|
||||||
<th class="text-center action-column">Actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
|
||||||
@foreach (var item in Model)
|
|
||||||
{
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>@item.Artiste</td>
|
<th>Artiste</th>
|
||||||
<td>@item.Titre</td>
|
<th>Titre</th>
|
||||||
<td>@item.Duree</td>
|
<th>Durée</th>
|
||||||
<td>@item.DateSortie.ToString("dd/MM/yyyy")</td>
|
<th>Date de sortie</th>
|
||||||
|
<th class="text-center"><i class="fa fa-eye"></i></th>
|
||||||
<td class="text-center">@item.NbLectures</td>
|
<th class="text-center"><i class="fa fa-thumbs-up"></i></th>
|
||||||
<td class="text-center">@item.NbLikes</td>
|
<th class="text-center"><i class="fa fa-comments"></i></th>
|
||||||
<td class="text-center">@item.NbCommentaires</td>
|
<th class="text-center action-column">Actions</th>
|
||||||
|
|
||||||
<td class="text-center action-column">
|
|
||||||
|
|
||||||
<a asp-action="Edit" asp-route-id="@item.Id"
|
|
||||||
class="btn btn-sm btn-outline-primary">
|
|
||||||
<i class="fa fa-pen"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a asp-action="Delete" asp-route-id="@item.Id"
|
|
||||||
class="btn btn-sm btn-outline-danger">
|
|
||||||
<i class="fa fa-trash"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
}
|
</thead>
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@item.Artiste</td>
|
||||||
|
<td>@item.Titre</td>
|
||||||
|
<td>@item.Duree</td>
|
||||||
|
<td>@item.DateSortie.ToString("dd/MM/yyyy")</td>
|
||||||
|
|
||||||
|
<td class="text-center">@item.NbLectures</td>
|
||||||
|
<td class="text-center">@item.NbLikes</td>
|
||||||
|
<td class="text-center">@item.NbCommentaires</td>
|
||||||
|
|
||||||
|
<td class="text-center action-column">
|
||||||
|
|
||||||
|
<a asp-action="Edit" asp-route-id="@item.Id"
|
||||||
|
class="btn btn-sm text-primary">
|
||||||
|
<i class="fa fa-edit"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a asp-action="Delete" asp-route-id="@item.Id"
|
||||||
|
class="btn btn-sm text-primary">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
Reference in New Issue
Block a user