From 909ed0e67b7ef12ee09227019aad1bf48e63099a Mon Sep 17 00:00:00 2001 From: Florlan Date: Thu, 5 Mar 2026 13:07:50 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Feat:=20Commentaire=20-=20cr=C3=A9ation=20d?= =?UTF-8?q?e=20la=20route=20commentaire=20dans=20program.cs=20-=20cr=C3=A9?= =?UTF-8?q?ation=20du=20CommentairesController=20-=20cr=C3=A9ation=20du=20?= =?UTF-8?q?CommentaireViewModel=20-=20cr=C3=A9ation=20de=20la=20vue=20inde?= =?UTF-8?q?x.cshtml=20des=20commentaire=20-=20cr=C3=A9ation=20du=20layout?= =?UTF-8?q?=20Admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Views/Commentaires/Index.cshtml | 90 +++++++++ .../Areas/Admin/Views/Shared/_Layout.cshtml | 181 ++++++++++++++++++ .../Controllers/CommentairesController.cs | 113 +++++++++++ Webzine.WebApplication/Program.cs | 6 + .../ViewModels/CommentaireViewModel.cs | 19 ++ .../Webzine.WebApplication.csproj | 9 +- 6 files changed, 416 insertions(+), 2 deletions(-) create mode 100644 Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml create mode 100644 Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml create mode 100644 Webzine.WebApplication/Controllers/CommentairesController.cs create mode 100644 Webzine.WebApplication/ViewModels/CommentaireViewModel.cs diff --git a/Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml b/Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml new file mode 100644 index 0000000..0199999 --- /dev/null +++ b/Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml @@ -0,0 +1,90 @@ +@using Webzine.WebApplication.ViewModels +@using Webzine.Entity +@model CommentaireViewModel + +@{ + ViewData["Title"] = "Commentaires"; + Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml"; +} + + + +

Commentaires

+ +
+ + + + + + + + + + + + @foreach (Webzine.Entity.Commentaire commentaire in Model.Commentaires) + { + + + + + + + + } + +
TitreAuteurCommentaireDate de créationActions
+ + @(commentaire.Titre != null ? commentaire.Titre.Libelle : "Titre inconnu") + + + @commentaire.Auteur + + @commentaire.Contenu + + @commentaire.DateCreation.ToString("dd/MM/yyyy HH:mm:ss") + + +
+ @Html.AntiForgeryToken() + +
+
+
diff --git a/Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml b/Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..559941b --- /dev/null +++ b/Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml @@ -0,0 +1,181 @@ + + + + + + @ViewData["Title"] - Administration + + + + + + +
+
+ @RenderBody() +
+
+ + \ No newline at end of file diff --git a/Webzine.WebApplication/Controllers/CommentairesController.cs b/Webzine.WebApplication/Controllers/CommentairesController.cs new file mode 100644 index 0000000..9c60b25 --- /dev/null +++ b/Webzine.WebApplication/Controllers/CommentairesController.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Webzine.Entity; +using Webzine.WebApplication.ViewModels; + +namespace Webzine.WebApplication.Controllers +{ + [Area("Admin")] + public class CommentairesController : Controller + { + // GET: Admin/Commentaires + public ActionResult Index() + { + // Création de données "bouchon" (mock) pour tester l'affichage + var listeCommentaires = new List + { + new Commentaire + { + IdCommentaire = 1, // Correction: Id -> IdCommentaire + Auteur = "Michel", // Correction: Nom -> Auteur + Contenu = "Nulla sed velit nec tellus gravida molestie", + DateCreation = new DateTime(2023, 1, 22, 15, 59, 28), + // Important : On initialise l'objet Titre pour accéder à Titre.Libelle + Titre = new Titre { Libelle = "St Germain - So Flute" }, + }, + new Commentaire + { + IdCommentaire = 2, + Auteur = "Jeff", + Contenu = "Lorem ipsum dolor sit.", + DateCreation = new DateTime(2023, 1, 22, 14, 27, 8), + Titre = new Titre { Libelle = "Queen - Bohemian Rapsody" }, + }, + new Commentaire + { + IdCommentaire = 3, + Auteur = "Eva", + Contenu = "Aenean vulputate eleifend tellus.", + DateCreation = new DateTime(2023, 1, 22, 13, 2, 17), + Titre = new Titre { Libelle = "Rammstein - Du hast" }, + }, + }; + + // Initialisation du ViewModel + var viewModel = new CommentaireViewModel + { + Commentaires = listeCommentaires + }; + + return View(viewModel); + } + + + + // GET: CommentairesController/Details/5 + public ActionResult Details(int id) + { + return View(); + } + + // GET: CommentairesController/Create + public ActionResult Create() + { + return View(); + } + + // POST: CommentairesController/Create + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Create(IFormCollection collection) + { + try + { + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: CommentairesController/Edit/5 + public ActionResult Edit(int id) + { + return View(); + } + + // POST: CommentairesController/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Edit(int id, IFormCollection collection) + { + try + { + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: CommentairesController/Delete/5 + public ActionResult Delete(int id) + { + return View(); + } + + // POST: CommentairesController/Delete/5 + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/Program.cs b/Webzine.WebApplication/Program.cs index 575f1cf..c9ca7ea 100644 --- a/Webzine.WebApplication/Program.cs +++ b/Webzine.WebApplication/Program.cs @@ -30,6 +30,12 @@ try // Active le middleware permettant le routage des requ�tes entrantes. app.UseRouting(); + + // Ajoute une route pour les zones (Areas) comme Admin + app.MapControllerRoute( + name: "areas", + pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); + // Ajoute un endpoint permettant de router les urls // avec la forme /controller/action/id(optionnel). // Equivalent � app.MapDefaultControllerRoute() diff --git a/Webzine.WebApplication/ViewModels/CommentaireViewModel.cs b/Webzine.WebApplication/ViewModels/CommentaireViewModel.cs new file mode 100644 index 0000000..cbd09da --- /dev/null +++ b/Webzine.WebApplication/ViewModels/CommentaireViewModel.cs @@ -0,0 +1,19 @@ +// +// Copyright (c) Webzine. All rights reserved. +// + +using Webzine.Entity; + +namespace Webzine.WebApplication.ViewModels +{ + /// + /// ViewModel pour afficher la liste des commentaires en administration. + /// + public class CommentaireViewModel + { + /// + /// Obtient ou définit la liste des commentaires. + /// + public IEnumerable Commentaires { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/Webzine.WebApplication.csproj b/Webzine.WebApplication/Webzine.WebApplication.csproj index 5651896..4f72671 100644 --- a/Webzine.WebApplication/Webzine.WebApplication.csproj +++ b/Webzine.WebApplication/Webzine.WebApplication.csproj @@ -17,6 +17,7 @@ + @@ -25,12 +26,16 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + + From aa5bffee27e6200debce0c496fa131395221ac0e Mon Sep 17 00:00:00 2001 From: "b.nodon" Date: Thu, 5 Mar 2026 13:22:36 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Feat:=20Commentaire=20-=20cr=C3=A9ation=20d?= =?UTF-8?q?e=20la=20route=20commentaire=20dans=20program.cs=20-=20cr=C3=A9?= =?UTF-8?q?ation=20du=20CommentairesController=20-=20cr=C3=A9ation=20du=20?= =?UTF-8?q?CommentaireViewModel=20-=20cr=C3=A9ation=20de=20la=20vue=20inde?= =?UTF-8?q?x.cshtml=20des=20commentaire=20-=20cr=C3=A9ation=20du=20layout?= =?UTF-8?q?=20Admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Views/Commentaires/Index.cshtml | 90 +++++++++ .../Areas/Admin/Views/Shared/_Layout.cshtml | 181 ++++++++++++++++++ .../Controllers/CommentairesController.cs | 113 +++++++++++ Webzine.WebApplication/Program.cs | 6 + .../ViewModels/CommentaireViewModel.cs | 19 ++ .../Webzine.WebApplication.csproj | 9 +- 6 files changed, 416 insertions(+), 2 deletions(-) create mode 100644 Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml create mode 100644 Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml create mode 100644 Webzine.WebApplication/Controllers/CommentairesController.cs create mode 100644 Webzine.WebApplication/ViewModels/CommentaireViewModel.cs diff --git a/Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml b/Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml new file mode 100644 index 0000000..0199999 --- /dev/null +++ b/Webzine.WebApplication/Areas/Admin/Views/Commentaires/Index.cshtml @@ -0,0 +1,90 @@ +@using Webzine.WebApplication.ViewModels +@using Webzine.Entity +@model CommentaireViewModel + +@{ + ViewData["Title"] = "Commentaires"; + Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml"; +} + + + +

Commentaires

+ +
+ + + + + + + + + + + + @foreach (Webzine.Entity.Commentaire commentaire in Model.Commentaires) + { + + + + + + + + } + +
TitreAuteurCommentaireDate de créationActions
+ + @(commentaire.Titre != null ? commentaire.Titre.Libelle : "Titre inconnu") + + + @commentaire.Auteur + + @commentaire.Contenu + + @commentaire.DateCreation.ToString("dd/MM/yyyy HH:mm:ss") + + +
+ @Html.AntiForgeryToken() + +
+
+
diff --git a/Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml b/Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..559941b --- /dev/null +++ b/Webzine.WebApplication/Areas/Admin/Views/Shared/_Layout.cshtml @@ -0,0 +1,181 @@ + + + + + + @ViewData["Title"] - Administration + + + + + + +
+
+ @RenderBody() +
+
+ + \ No newline at end of file diff --git a/Webzine.WebApplication/Controllers/CommentairesController.cs b/Webzine.WebApplication/Controllers/CommentairesController.cs new file mode 100644 index 0000000..9c60b25 --- /dev/null +++ b/Webzine.WebApplication/Controllers/CommentairesController.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Webzine.Entity; +using Webzine.WebApplication.ViewModels; + +namespace Webzine.WebApplication.Controllers +{ + [Area("Admin")] + public class CommentairesController : Controller + { + // GET: Admin/Commentaires + public ActionResult Index() + { + // Création de données "bouchon" (mock) pour tester l'affichage + var listeCommentaires = new List + { + new Commentaire + { + IdCommentaire = 1, // Correction: Id -> IdCommentaire + Auteur = "Michel", // Correction: Nom -> Auteur + Contenu = "Nulla sed velit nec tellus gravida molestie", + DateCreation = new DateTime(2023, 1, 22, 15, 59, 28), + // Important : On initialise l'objet Titre pour accéder à Titre.Libelle + Titre = new Titre { Libelle = "St Germain - So Flute" }, + }, + new Commentaire + { + IdCommentaire = 2, + Auteur = "Jeff", + Contenu = "Lorem ipsum dolor sit.", + DateCreation = new DateTime(2023, 1, 22, 14, 27, 8), + Titre = new Titre { Libelle = "Queen - Bohemian Rapsody" }, + }, + new Commentaire + { + IdCommentaire = 3, + Auteur = "Eva", + Contenu = "Aenean vulputate eleifend tellus.", + DateCreation = new DateTime(2023, 1, 22, 13, 2, 17), + Titre = new Titre { Libelle = "Rammstein - Du hast" }, + }, + }; + + // Initialisation du ViewModel + var viewModel = new CommentaireViewModel + { + Commentaires = listeCommentaires + }; + + return View(viewModel); + } + + + + // GET: CommentairesController/Details/5 + public ActionResult Details(int id) + { + return View(); + } + + // GET: CommentairesController/Create + public ActionResult Create() + { + return View(); + } + + // POST: CommentairesController/Create + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Create(IFormCollection collection) + { + try + { + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: CommentairesController/Edit/5 + public ActionResult Edit(int id) + { + return View(); + } + + // POST: CommentairesController/Edit/5 + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Edit(int id, IFormCollection collection) + { + try + { + return RedirectToAction(nameof(Index)); + } + catch + { + return View(); + } + } + + // GET: CommentairesController/Delete/5 + public ActionResult Delete(int id) + { + return View(); + } + + // POST: CommentairesController/Delete/5 + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/Program.cs b/Webzine.WebApplication/Program.cs index 575f1cf..c9ca7ea 100644 --- a/Webzine.WebApplication/Program.cs +++ b/Webzine.WebApplication/Program.cs @@ -30,6 +30,12 @@ try // Active le middleware permettant le routage des requ�tes entrantes. app.UseRouting(); + + // Ajoute une route pour les zones (Areas) comme Admin + app.MapControllerRoute( + name: "areas", + pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); + // Ajoute un endpoint permettant de router les urls // avec la forme /controller/action/id(optionnel). // Equivalent � app.MapDefaultControllerRoute() diff --git a/Webzine.WebApplication/ViewModels/CommentaireViewModel.cs b/Webzine.WebApplication/ViewModels/CommentaireViewModel.cs new file mode 100644 index 0000000..cbd09da --- /dev/null +++ b/Webzine.WebApplication/ViewModels/CommentaireViewModel.cs @@ -0,0 +1,19 @@ +// +// Copyright (c) Webzine. All rights reserved. +// + +using Webzine.Entity; + +namespace Webzine.WebApplication.ViewModels +{ + /// + /// ViewModel pour afficher la liste des commentaires en administration. + /// + public class CommentaireViewModel + { + /// + /// Obtient ou définit la liste des commentaires. + /// + public IEnumerable Commentaires { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/Webzine.WebApplication.csproj b/Webzine.WebApplication/Webzine.WebApplication.csproj index 5651896..4f72671 100644 --- a/Webzine.WebApplication/Webzine.WebApplication.csproj +++ b/Webzine.WebApplication/Webzine.WebApplication.csproj @@ -17,6 +17,7 @@
+ @@ -25,12 +26,16 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + +