Merge branch 'J1/admin/commentaire' into J1/feat/AdminTitreIHM
# Conflicts: # Webzine.WebApplication/Webzine.WebApplication.csproj
This commit is contained in:
@@ -4,22 +4,22 @@ using Webzine.Entity;
|
|||||||
using Webzine.Entity.Fixtures;
|
using Webzine.Entity.Fixtures;
|
||||||
using Webzine.WebApplication.ViewModels.Admin.Titre;
|
using Webzine.WebApplication.ViewModels.Admin.Titre;
|
||||||
|
|
||||||
namespace Webzine.WebApplication.Controllers.Admin;
|
namespace Webzine.WebApplication.Areas.Admin.Controllers;
|
||||||
|
|
||||||
public class Titre2Controller : Controller
|
public class TitreController : Microsoft.AspNetCore.Mvc.Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<Titre2Controller> _logger;
|
private readonly ILogger<TitreController> _logger;
|
||||||
private readonly List<Titre> _titres;
|
private readonly List<Titre> _titres;
|
||||||
private readonly List<Style> _styles;
|
private readonly List<Style> _styles;
|
||||||
private readonly List<Artiste> _artistes;
|
private readonly List<Artiste> _artistes;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialise une nouvelle instance du <see cref="Titre2Controller"/>.
|
/// Initialise une nouvelle instance du <see cref="TitreController"/>.
|
||||||
/// 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 Titre2Controller(ILogger<Titre2Controller> logger)
|
public TitreController(ILogger<TitreController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
@using Webzine.WebApplication.ViewModels
|
||||||
|
@using Webzine.Entity
|
||||||
|
@model CommentaireViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Commentaires";
|
||||||
|
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
|
||||||
|
}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.commentaires-container {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commentaires-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commentaires-table thead {
|
||||||
|
background: #ddd;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.commentaires-table th, .commentaires-table td {
|
||||||
|
padding: 1rem;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-delete {
|
||||||
|
color: #0066cc;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-delete:hover {
|
||||||
|
color: #ff4444;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<h1>Commentaires</h1>
|
||||||
|
|
||||||
|
<div class="commentaires-container">
|
||||||
|
<table class="commentaires-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Titre</th>
|
||||||
|
<th>Auteur</th>
|
||||||
|
<th>Commentaire</th>
|
||||||
|
<th>Date de création</th>
|
||||||
|
<th style="text-align: center;">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (Webzine.Entity.Commentaire commentaire in Model.Commentaires)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<!-- Titre est un objet, on affiche sa propriété Libelle -->
|
||||||
|
@(commentaire.Titre != null ? commentaire.Titre.Libelle : "Titre inconnu")
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<!-- On utilise Auteur (et pas Nom) -->
|
||||||
|
@commentaire.Auteur
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@commentaire.Contenu
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@commentaire.DateCreation.ToString("dd/MM/yyyy HH:mm:ss")
|
||||||
|
</td>
|
||||||
|
<td style="text-align: center;">
|
||||||
|
<!-- On utilise IdCommentaire (et pas Id) -->
|
||||||
|
<form method="post" action="@Url.Action("Delete", new { id = commentaire.IdCommentaire })" style="display: inline;">
|
||||||
|
@Html.AntiForgeryToken()
|
||||||
|
<button type="submit" class="btn-delete" title="Supprimer">
|
||||||
|
<i class="fas fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>@ViewData["Title"] - Webzine</title>
|
||||||
|
|
||||||
|
@* Ajout de bootstrap *@
|
||||||
|
<script src="/js/bootstrap.min.js" defer></script>
|
||||||
|
<link rel="stylesheet" href="/css/app.css">
|
||||||
|
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
||||||
|
|
||||||
|
@* Ajout de font-awesome *@
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
@await Html.PartialAsync("_Header")
|
||||||
|
<div class="row mt-5">
|
||||||
|
<main class="col-9">
|
||||||
|
@RenderBody()
|
||||||
|
</main>
|
||||||
|
@await Html.PartialAsync("_Sidebar")
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
|
|
||||||
namespace Webzine.WebApplication.Controllers
|
namespace Webzine.WebApplication.Controllers
|
||||||
{
|
{
|
||||||
public class AccueilController : Microsoft.AspNetCore.Mvc.Controller
|
public class AccueilController : Controller
|
||||||
{
|
{
|
||||||
// GET: AccueilController
|
// GET: AccueilController
|
||||||
public ActionResult Index()
|
public ActionResult Index()
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Webzine.WebApplication.Controller;
|
namespace Webzine.WebApplication.Controllers;
|
||||||
|
|
||||||
public class ApiController : ControllerBase
|
public class ApiController : ControllerBase
|
||||||
{
|
{
|
||||||
@@ -3,7 +3,7 @@ using Webzine.Entity;
|
|||||||
using Webzine.Entity.Fixtures;
|
using Webzine.Entity.Fixtures;
|
||||||
using Webzine.WebApplication.ViewsModels.Titre;
|
using Webzine.WebApplication.ViewsModels.Titre;
|
||||||
|
|
||||||
namespace Webzine.WebApplication.Controller;
|
namespace Webzine.WebApplication.Controllers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contrôleur responsable de la gestion des titres musicaux :
|
/// Contrôleur responsable de la gestion des titres musicaux :
|
||||||
@@ -11,7 +11,7 @@ namespace Webzine.WebApplication.Controller;
|
|||||||
/// ajout de likes et commentaires.
|
/// ajout de likes et commentaires.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("titre")]
|
[Route("titre")]
|
||||||
public class TitreController : Microsoft.AspNetCore.Mvc.Controller
|
public class TitreController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<TitreController> _logger;
|
private readonly ILogger<TitreController> _logger;
|
||||||
private readonly List<Titre> _titres;
|
private readonly List<Titre> _titres;
|
||||||
@@ -30,6 +30,12 @@ try
|
|||||||
// Active le middleware permettant le routage des requétes entrantes.
|
// Active le middleware permettant le routage des requétes entrantes.
|
||||||
app.UseRouting();
|
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
|
// Ajoute un endpoint permettant de router les urls
|
||||||
// avec la forme /controller/action/id(optionnel).
|
// avec la forme /controller/action/id(optionnel).
|
||||||
app.MapControllerRoute(
|
app.MapControllerRoute(
|
||||||
|
|||||||
19
Webzine.WebApplication/ViewModels/CommentaireViewModel.cs
Normal file
19
Webzine.WebApplication/ViewModels/CommentaireViewModel.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// <copyright file="CommentaireViewModel.cs" company="Webzine">
|
||||||
|
// Copyright (c) Webzine. All rights reserved.
|
||||||
|
// </copyright>
|
||||||
|
|
||||||
|
using Webzine.Entity;
|
||||||
|
|
||||||
|
namespace Webzine.WebApplication.ViewModels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ViewModel pour afficher la liste des commentaires en administration.
|
||||||
|
/// </summary>
|
||||||
|
public class CommentaireViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Obtient ou définit la liste des commentaires.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<Commentaire> Commentaires { get; set; } = new List<Commentaire>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,13 +7,6 @@
|
|||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="Views\Accueils\**" />
|
|
||||||
<Content Remove="Views\Accueils\**" />
|
|
||||||
<EmbeddedResource Remove="Views\Accueils\**" />
|
|
||||||
<None Remove="Views\Accueils\**" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\.dockerignore">
|
<Content Include="..\.dockerignore">
|
||||||
<Link>.dockerignore</Link>
|
<Link>.dockerignore</Link>
|
||||||
@@ -25,13 +18,14 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="wwwroot\data\" />
|
<Folder Include="wwwroot\data\" />
|
||||||
|
<Folder Include="wwwroot\js\" />
|
||||||
<Folder Include="wwwroot\lib\" />
|
<Folder Include="wwwroot\lib\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
<PackageReference Include="Faker.Net" Version="2.0.163" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="10.0.3" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="10.0.3" />
|
||||||
<PackageReference Include="NLog.Web.AspNetCore" Version="5.*" />
|
<PackageReference Include="NLog.Web.AspNetCore" Version="6.1.1" />
|
||||||
<PackageReference Include="NLog" Version="6.1.1" />
|
<PackageReference Include="NLog" Version="6.1.1" />
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
@@ -40,8 +34,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Webzine.Repository.Contracts\Webzine.Repository.Contracts.csproj" />
|
<ProjectReference Include="..\Webzine.Entity\Webzine.Entity.csproj" />
|
||||||
<ProjectReference Include="..\Webzine.Repository\Webzine.Repository.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user