Merge branch 'dev' into j3/feat/business-logic/titre-admin
# Conflicts: # Webzine.Business/Webzine.Business.csproj # Webzine.WebApplication/Program.cs
This commit is contained in:
26
.gitea/workflows/deploy-prod.yaml
Normal file
26
.gitea/workflows/deploy-prod.yaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Deploiement API Prod Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
name: Build et Déploiement
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 📥 Récupération du code source
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 🔐 Injection des variables d'environnement
|
||||||
|
run: |
|
||||||
|
echo "PGSQL_CONNECTION=${{ secrets.PGSQL_CONNECTION }}" > .env
|
||||||
|
|
||||||
|
- name: 🐳 Redémarrage Docker
|
||||||
|
run: |
|
||||||
|
echo "🚀 Démarrage du déploiement Docker sur api-prod..."
|
||||||
|
docker compose down
|
||||||
|
docker compose up -d --build
|
||||||
|
echo "✅ Déploiement terminé !"
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels;
|
namespace Webzine.Business.Contracts.Dto;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ViewModel pour le tableau de bord de l'administration du webzine.
|
/// DTO pour le tableau de bord de l'administration du webzine.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DashboardViewModel
|
public class DashboardDTO
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Définit le nombre total d'artistes chroniqués dans le webzine.
|
/// Définit le nombre total d'artistes chroniqués dans le webzine.
|
||||||
16
Webzine.Business.Contracts/IDashboardService.cs
Normal file
16
Webzine.Business.Contracts/IDashboardService.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Webzine.Business.Contracts.Dto;
|
||||||
|
|
||||||
|
namespace Webzine.Business.Contracts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Service responsable du calcul des statistiques affichées sur le tableau de bord d'administration.
|
||||||
|
/// Agrège les données provenant de plusieurs repositories pour produire un résumé cohérent.
|
||||||
|
/// </summary>
|
||||||
|
public interface IDashboardService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Calcule et retourne toutes les statistiques du tableau de bord en une seule passe.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Un <see cref="DashboardDTO"/> contenant les agrégats calculés.</returns>
|
||||||
|
DashboardDTO GetDashboardData();
|
||||||
|
}
|
||||||
71
Webzine.Business/DashboardService.cs
Normal file
71
Webzine.Business/DashboardService.cs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
using Webzine.Business.Contracts;
|
||||||
|
using Webzine.Entity;
|
||||||
|
using Webzine.Repository.Contracts;
|
||||||
|
|
||||||
|
namespace Webzine.Business;
|
||||||
|
|
||||||
|
using Contracts.Dto;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implémentation de <see cref="IDashboardService"/>.
|
||||||
|
/// Orchestre plusieurs appels aux repositories pour produire les statistiques du tableau de bord.
|
||||||
|
/// </summary>
|
||||||
|
public class DashboardService : IDashboardService
|
||||||
|
{
|
||||||
|
private readonly IArtisteRepository artisteRepository;
|
||||||
|
private readonly ITitreRepository titreRepository;
|
||||||
|
private readonly IStyleRepository styleRepository;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="DashboardService"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="artisteRepository">Repository des artistes.</param>
|
||||||
|
/// <param name="titreRepository">Repository des titres.</param>
|
||||||
|
/// <param name="styleRepository">Repository des styles.</param>
|
||||||
|
public DashboardService(
|
||||||
|
IArtisteRepository artisteRepository,
|
||||||
|
ITitreRepository titreRepository,
|
||||||
|
IStyleRepository styleRepository)
|
||||||
|
{
|
||||||
|
this.artisteRepository = artisteRepository;
|
||||||
|
this.titreRepository = titreRepository;
|
||||||
|
this.styleRepository = styleRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public DashboardDTO GetDashboardData()
|
||||||
|
{
|
||||||
|
IEnumerable<Titre> titres = this.titreRepository.FindAll();
|
||||||
|
|
||||||
|
Artiste? artisteLePlusChronique = titres
|
||||||
|
.GroupBy(t => t.Artiste)
|
||||||
|
.OrderByDescending(g => g.Count())
|
||||||
|
.FirstOrDefault()
|
||||||
|
?.Key;
|
||||||
|
|
||||||
|
Artiste? albumLePlusChronique = titres
|
||||||
|
.GroupBy(t => (t.Artiste, t.Album))
|
||||||
|
.GroupBy(g => g.Key.Artiste)
|
||||||
|
.OrderByDescending(g => g.Count())
|
||||||
|
.FirstOrDefault()
|
||||||
|
?.Key;
|
||||||
|
|
||||||
|
Titre? musiqueLaPlusJouee = titres
|
||||||
|
.OrderByDescending(t => t.NbLectures)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
return new DashboardDTO
|
||||||
|
{
|
||||||
|
NombreArtistes = this.artisteRepository.Count(),
|
||||||
|
ArtisteLePlusChronique = artisteLePlusChronique.Nom,
|
||||||
|
AlbumLePlusChronique = albumLePlusChronique.Nom,
|
||||||
|
NombreBiographies = this.artisteRepository.Count(a => !string.IsNullOrEmpty(a.Biographie)),
|
||||||
|
IdMusiqueLaPlusJouee = musiqueLaPlusJouee.IdTitre,
|
||||||
|
MusiqueLaPlusJouee = musiqueLaPlusJouee.Libelle,
|
||||||
|
NombreTitres = this.titreRepository.Count(),
|
||||||
|
NombreGenres = this.styleRepository.Count(),
|
||||||
|
NombreLectures = titres.Sum(t => t.NbLectures),
|
||||||
|
NombreLikes = titres.Sum(t => t.NbLikes),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -51,5 +51,18 @@ namespace Webzine.Repository.Contracts
|
|||||||
/// <param name="nom">Nom de l'artiste.</param>
|
/// <param name="nom">Nom de l'artiste.</param>
|
||||||
/// <returns>IEnumarble.<Artiste> qui contient la chaine de caractere.</returns>
|
/// <returns>IEnumarble.<Artiste> qui contient la chaine de caractere.</returns>
|
||||||
IEnumerable<Artiste> Search(string nom);
|
IEnumerable<Artiste> Search(string nom);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Récupère le nombre total d'artistes dans la collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Le nombre total d'artistes.</returns>
|
||||||
|
int Count();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Récupère le nombre d'artistes correspondant au prédicat fourni.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="predicate">Le prédicat de filtrage.</param>
|
||||||
|
/// <returns>Le nombre d'artistes correspondants.</returns>
|
||||||
|
int Count(Func<Artiste, bool> predicate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,5 +37,11 @@ namespace Webzine.Repository.Contracts
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="style">L'objet style à mettre à jour.</param
|
/// <param name="style">L'objet style à mettre à jour.</param
|
||||||
void Update(Style style);
|
void Update(Style style);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Récupère le nombre total de styles dans la liste des styles.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Le nombre total de styles présents dans la liste.</returns>
|
||||||
|
int Count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,8 +83,8 @@ namespace Webzine.Repository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Artiste artiste = this.context.Artistes
|
Artiste artiste = this.context.Artistes
|
||||||
.Include(a => a.Titres)
|
.Include(a => a.Titres)
|
||||||
.First(a => a.IdArtiste == id);
|
.FirstOrDefault(a => a.IdArtiste == id);
|
||||||
return artiste;
|
return artiste;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -176,5 +176,37 @@ namespace Webzine.Repository
|
|||||||
throw new Exception("Erreur lors de la recherche d'artiste {error}", ex);
|
throw new Exception("Erreur lors de la recherche d'artiste {error}", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int Count()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int count = Enumerable.Count(this.context.Artistes);
|
||||||
|
this.logger.LogDebug("Nombre total d'artistes dans la base: {Count}", count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.logger.LogError(ex, "Erreur lors du comptage des artistes.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int Count(Func<Artiste, bool> predicate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int count = this.context.Artistes.Count(predicate);
|
||||||
|
this.logger.LogDebug("Nombre d'artistes (avec prédicat): {Count}", count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.logger.LogError(ex, "Erreur lors du comptage des artistes avec prédicat.");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,4 +178,20 @@ public class DbStyleRepository : IStyleRepository
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int Count()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int count = Enumerable.Count(this.context.Styles);
|
||||||
|
this.logger.LogDebug("Nombre total de styles: {Count}", count);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.logger.LogError(ex, "Erreur lors du comptage des styles");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -245,15 +245,13 @@ public class DbTitreRepository : ITitreRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.logger.LogDebug("Recherche du titre avec l'ID: {IdTitre}", idTitre);
|
this.logger.LogDebug("Recherche du titre avec l'ID: {IdTitre}", idTitre);
|
||||||
this.logger.LogDebug("Préparation de la requête avec les inclusions Artiste, Styles et Commentaires");
|
|
||||||
|
|
||||||
var titre = this.context.Titres
|
var titre = this.context.Titres
|
||||||
.Include(t => t.Artiste)
|
.Include(t => t.Artiste)
|
||||||
.Include(t => t.Styles)
|
.Include(t => t.Styles)
|
||||||
.Include(t => t.Commentaires)
|
.Include(t => t.Commentaires)
|
||||||
.First(t => t.IdTitre == idTitre);
|
.FirstOrDefault(t => t.IdTitre == idTitre);
|
||||||
|
|
||||||
this.logger.LogDebug("Titre trouvé: {Libelle}", titre.Libelle);
|
|
||||||
return titre;
|
return titre;
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
|
|||||||
@@ -93,5 +93,17 @@ namespace Webzine.Repository
|
|||||||
.Where(a => a.Nom.ToLower().Contains(mot.ToLower()))
|
.Where(a => a.Nom.ToLower().Contains(mot.ToLower()))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int Count()
|
||||||
|
{
|
||||||
|
return this.dataStore.Artistes.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int Count(Func<Artiste, bool> predicate)
|
||||||
|
{
|
||||||
|
return this.dataStore.Artistes.Count(predicate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,4 +56,10 @@ public class LocalStyleRepository : IStyleRepository
|
|||||||
{
|
{
|
||||||
throw new NotSupportedException("Mode local");
|
throw new NotSupportedException("Mode local");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public int Count()
|
||||||
|
{
|
||||||
|
return this.dataStore.Styles.Count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -50,14 +50,37 @@ public class ArtisteController : Controller
|
|||||||
/// <returns>Redirection.</returns>
|
/// <returns>Redirection.</returns>
|
||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
var model = new AdminArtisteForm
|
return this.View();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Formulaire de création d'un artiste.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Paramètre nécessaire pour la création d'un artiste.</param>
|
||||||
|
/// <returns>Redirection sur la page Index.</returns>
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Create(ArtisteCreateViewModel model)
|
||||||
|
{
|
||||||
|
// vérifier si les données sont corrects.
|
||||||
|
if (!this.ModelState.IsValid)
|
||||||
{
|
{
|
||||||
Id = 0,
|
// Passer model en paramètre afin que
|
||||||
Nom = string.Empty,
|
// l'utilisateur conserve sa saissie.
|
||||||
Biographie = string.Empty,
|
return this.View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Créer un objet Artiste avecc les paramètres.
|
||||||
|
var artiste = new Artiste
|
||||||
|
{
|
||||||
|
Nom = model.Nom,
|
||||||
|
Biographie = model.Biographie,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.View(model);
|
// Persister les données.
|
||||||
|
this.artisteRepository.Add(artiste);
|
||||||
|
|
||||||
|
// Renvoyer sur la page Index.
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -69,14 +92,37 @@ public class ArtisteController : Controller
|
|||||||
{
|
{
|
||||||
var artiste = this.artisteRepository.Find(id);
|
var artiste = this.artisteRepository.Find(id);
|
||||||
|
|
||||||
var model = new AdminArtisteForm
|
if (artiste == null)
|
||||||
{
|
{
|
||||||
Id = artiste.IdArtiste,
|
return this.RedirectToAction("Index");
|
||||||
Nom = artiste.Nom,
|
}
|
||||||
Biographie = artiste.Biographie,
|
|
||||||
|
return this.View(artiste);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Traitement du formulaire de modification d'un artiste.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Paramètre d'un artiste.</param>
|
||||||
|
/// <returns>Redirection sur Index.</returns>
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Edit(ArtisteEditViewModel model)
|
||||||
|
{
|
||||||
|
var artiste = new Artiste
|
||||||
|
{
|
||||||
|
IdArtiste = model.Id,
|
||||||
|
Nom = model.Nom,
|
||||||
|
Biographie = model.Biographie,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.View(model);
|
if (!this.ModelState.IsValid)
|
||||||
|
{
|
||||||
|
return this.View(artiste);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.artisteRepository.Update(artiste);
|
||||||
|
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -87,6 +133,12 @@ public class ArtisteController : Controller
|
|||||||
public IActionResult Delete(int id)
|
public IActionResult Delete(int id)
|
||||||
{
|
{
|
||||||
var artiste = this.artisteRepository.Find(id);
|
var artiste = this.artisteRepository.Find(id);
|
||||||
|
|
||||||
|
if (artiste == null)
|
||||||
|
{
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
var model = new AdminArtisteForm
|
var model = new AdminArtisteForm
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ namespace Webzine.WebApplication.Areas.Administration.Controllers
|
|||||||
{
|
{
|
||||||
var commentaire = this.commentaireRepository.Find(id);
|
var commentaire = this.commentaireRepository.Find(id);
|
||||||
|
|
||||||
|
if (commentaire == null)
|
||||||
|
{
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
var model = new CommentaireDeleteViewModel
|
var model = new CommentaireDeleteViewModel
|
||||||
{
|
{
|
||||||
IdCommentaire = commentaire.IdCommentaire,
|
IdCommentaire = commentaire.IdCommentaire,
|
||||||
|
|||||||
@@ -1,30 +1,26 @@
|
|||||||
namespace Webzine.WebApplication.Areas.Administration.Controllers;
|
namespace Webzine.WebApplication.Areas.Administration.Controllers;
|
||||||
|
|
||||||
|
using Webzine.Business.Contracts;
|
||||||
|
using Webzine.Business.Contracts.Dto;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
using Webzine.Repository.Contracts;
|
using Webzine.Repository.Contracts;
|
||||||
using Webzine.WebApplication.Areas.Administration.ViewModels;
|
|
||||||
|
|
||||||
[Area("Administration")]
|
[Area("Administration")]
|
||||||
public class DashboardController : Controller
|
public class DashboardController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<DashboardController> logger;
|
private readonly ILogger<DashboardController> logger;
|
||||||
private readonly IStyleRepository styleRepository;
|
private readonly IDashboardService dashboardService;
|
||||||
private readonly IArtisteRepository artisteRepository;
|
|
||||||
private readonly ITitreRepository titreRepository;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="DashboardController"/> class.
|
/// Initializes a new instance of the <see cref="DashboardController"/> class.
|
||||||
/// Initialise une nouvelle instance de la classe <see cref="DashboardController"/>.
|
/// Initialise une nouvelle instance de la classe <see cref="DashboardController"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="logger">Service de journalisation injecté.</param>
|
/// <param name="logger">Service de journalisation injecté.</param>
|
||||||
/// <param name="styleRepository">Repository des styles injecté.</param>
|
/// <param name="dashboardService">Service de calcul des statistiques du tableau de bord.</param>
|
||||||
public DashboardController(ILogger<DashboardController> logger, IStyleRepository styleRepository, IArtisteRepository artisteRepository, ITitreRepository titreRepository)
|
public DashboardController(ILogger<DashboardController> logger, IDashboardService dashboardService)
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.styleRepository = styleRepository;
|
this.dashboardService = dashboardService;
|
||||||
this.artisteRepository = artisteRepository;
|
|
||||||
this.titreRepository = titreRepository;
|
|
||||||
|
|
||||||
this.logger.LogInformation("Initialisation du contrôleur TitreController.");
|
this.logger.LogInformation("Initialisation du contrôleur TitreController.");
|
||||||
}
|
}
|
||||||
@@ -35,42 +31,8 @@ public class DashboardController : Controller
|
|||||||
/// <returns>La vue Index du tableau de bord.</returns>
|
/// <returns>La vue Index du tableau de bord.</returns>
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
var artisteLePlusChronique = this.titreRepository.FindAll()
|
DashboardDTO data = dashboardService.GetDashboardData();
|
||||||
.GroupBy(t => t.Artiste)
|
|
||||||
.OrderByDescending(g => g.Count())
|
|
||||||
.First();
|
|
||||||
|
|
||||||
var albumLePlusChronique = this.titreRepository.FindAll()
|
return this.View(data);
|
||||||
.GroupBy(t => t.Artiste)
|
|
||||||
.OrderByDescending(g => g.Select(t => t.Album).Distinct().Count())
|
|
||||||
.First();
|
|
||||||
|
|
||||||
var musiqueLaPlusJouee = this.titreRepository.FindAll()
|
|
||||||
.OrderByDescending(t => t.NbLectures)
|
|
||||||
.First();
|
|
||||||
|
|
||||||
var model = new DashboardViewModel
|
|
||||||
{
|
|
||||||
NombreArtistes = this.artisteRepository.FindAll().Count(),
|
|
||||||
|
|
||||||
ArtisteLePlusChronique = artisteLePlusChronique.Key.Nom,
|
|
||||||
|
|
||||||
AlbumLePlusChronique = albumLePlusChronique.Key.Nom,
|
|
||||||
|
|
||||||
NombreBiographies = this.artisteRepository.FindAll().Count(a => !string.IsNullOrEmpty(a.Biographie)),
|
|
||||||
|
|
||||||
IdMusiqueLaPlusJouee = musiqueLaPlusJouee.IdTitre,
|
|
||||||
MusiqueLaPlusJouee = musiqueLaPlusJouee.Libelle,
|
|
||||||
|
|
||||||
NombreTitres = this.titreRepository.Count(),
|
|
||||||
|
|
||||||
NombreGenres = this.styleRepository.FindAll().Count(),
|
|
||||||
|
|
||||||
NombreLectures = this.titreRepository.FindAll().Sum(t => t.NbLectures),
|
|
||||||
|
|
||||||
NombreLikes = this.titreRepository.FindAll().Sum(t => t.NbLikes),
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.View(model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,109 +1,170 @@
|
|||||||
namespace Webzine.WebApplication.Areas.Administration.Controllers
|
namespace Webzine.WebApplication.Areas.Administration.Controllers;
|
||||||
{
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
using Webzine.Repository.Contracts;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Webzine.WebApplication.Areas.Administration.ViewModels.Style;
|
|
||||||
|
using Webzine.Entity;
|
||||||
|
using Webzine.Repository.Contracts;
|
||||||
|
using Webzine.WebApplication.Areas.Administration.ViewModels.Style;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controleur pour la gestion des styles dans l'administration du webzine.
|
||||||
|
/// </summary>
|
||||||
|
[Area("Administration")]
|
||||||
|
public class StyleController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<StyleController> logger;
|
||||||
|
private readonly IStyleRepository styleRepository;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Contrôleur pour la gestion des styles dans l'administration du webzine.
|
/// Initializes a new instance of the <see cref="StyleController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Area("Administration")]
|
/// <param name="logger">Service de journalisation injecte.</param>
|
||||||
public class StyleController : Controller
|
/// <param name="styleRepository">Repository des styles injecte.</param>
|
||||||
|
public StyleController(
|
||||||
|
ILogger<StyleController> logger,
|
||||||
|
IStyleRepository styleRepository)
|
||||||
{
|
{
|
||||||
private readonly ILogger<StyleController> logger;
|
this.logger = logger;
|
||||||
private readonly IStyleRepository styleRepository;
|
this.styleRepository = styleRepository;
|
||||||
|
|
||||||
/// <summary>
|
this.logger.LogInformation("Initialisation du controleur StyleController.");
|
||||||
/// Initializes a new instance of the <see cref="StyleController"/> class.
|
}
|
||||||
/// Initialise une nouvelle instance de la classe <see cref="StyleController"/>.
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="logger">Service de journalisation injecté.</param>
|
/// Affiche la liste des styles dans la vue Index.
|
||||||
/// <param name="styles">Repository des styles injecté.</param>
|
/// </summary>
|
||||||
public StyleController(
|
/// <returns>La vue Index avec la liste des styles.</returns>
|
||||||
ILogger<StyleController> logger,
|
public IActionResult Index()
|
||||||
IStyleRepository styleRepository)
|
{
|
||||||
|
IEnumerable<Style> listeStyles = this.styleRepository.FindAll().Take(10);
|
||||||
|
|
||||||
|
return this.View(listeStyles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Affiche la vue de creation d'un nouveau style.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>La vue Create pour ajouter un nouveau style.</returns>
|
||||||
|
public IActionResult Create()
|
||||||
|
{
|
||||||
|
var model = new StyleCreateViewModel
|
||||||
{
|
{
|
||||||
this.logger = logger;
|
Libelle = string.Empty,
|
||||||
|
};
|
||||||
|
|
||||||
this.logger.LogInformation("Initialisation du contrôleur StyleController.");
|
return this.View(model);
|
||||||
|
}
|
||||||
|
|
||||||
this.styleRepository = styleRepository;
|
/// <summary>
|
||||||
|
/// Cree un nouveau style.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Nouveau style.</param>
|
||||||
|
/// <returns>IActionResult.</returns>
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Create(StyleCreateViewModel model)
|
||||||
|
{
|
||||||
|
if (!this.ModelState.IsValid)
|
||||||
|
{
|
||||||
|
return this.View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
var style = new Style
|
||||||
/// Affiche la liste des styles dans la vue Index.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>La vue Index avec le ViewModel contenant la liste des styles.</returns>
|
|
||||||
public IActionResult Index()
|
|
||||||
{
|
{
|
||||||
var listeStyles = this.styleRepository.FindAll().Take(10);
|
Libelle = model.Libelle,
|
||||||
|
};
|
||||||
|
|
||||||
return this.View(listeStyles);
|
this.styleRepository.Add(style);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
return this.RedirectToAction("Index");
|
||||||
/// Affiche la vue de création d'un nouveau style.
|
}
|
||||||
/// </summary>
|
|
||||||
/// <returns>La vue Create pour ajouter un nouveau style.</returns>
|
/// <summary>
|
||||||
public IActionResult Create()
|
/// Affiche la vue de confirmation de suppression d'un style.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">L'identifiant du style a supprimer.</param>
|
||||||
|
/// <returns>La vue de confirmation ou une redirection vers l'index si le style n'existe pas.</returns>
|
||||||
|
public IActionResult Delete(int id)
|
||||||
|
{
|
||||||
|
var style = this.styleRepository.Find(id);
|
||||||
|
|
||||||
|
if (style == null || style.IdStyle == 0)
|
||||||
{
|
{
|
||||||
return this.View();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Affiche la vue de confirmation de suppression d'un style, en récupérant les détails du style à supprimer à partir de l'identifiant fourni.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">L'identifiant du style à supprimer.</param>
|
|
||||||
/// <returns>La vue de confirmation de suppression avec le ViewModel contenant les détails du style à supprimer, ou une redirection vers l'index si le style n'existe pas.</returns>
|
|
||||||
public IActionResult Delete(int id)
|
|
||||||
{
|
|
||||||
var style = this.styleRepository.Find(id);
|
|
||||||
|
|
||||||
var vm = new StyleDeleteViewModel
|
|
||||||
{
|
|
||||||
IdStyle = style.IdStyle,
|
|
||||||
Libelle = style.Libelle,
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.View(vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Méthode POST pour supprimer un style.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="model">Le style à supprimer.</param>
|
|
||||||
/// <returns>Redirige vers la page d'index d'admin style.</returns>
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult Delete(StyleEditViewModel model)
|
|
||||||
{
|
|
||||||
var style = this.styleRepository.Find(model.IdStyle);
|
|
||||||
|
|
||||||
if (style != null)
|
|
||||||
{
|
|
||||||
this.styleRepository.Delete(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.RedirectToAction("Index");
|
return this.RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
var model = new StyleDeleteViewModel
|
||||||
/// Affiche la vue d'édition d'un style existant, en récupérant les détails du style à éditer à partir de l'identifiant fourni.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id">L'identifiant du style à éditer.</param>
|
|
||||||
/// <returns>La vue d'édition avec le ViewModel contenant les détails du style à éditer, ou une redirection vers l'index si le style n'existe pas.</returns>
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Edit(int id)
|
|
||||||
{
|
{
|
||||||
var style = this.styleRepository.Find(id);
|
IdStyle = style.IdStyle,
|
||||||
|
Libelle = style.Libelle,
|
||||||
|
};
|
||||||
|
|
||||||
var model = new StyleEditViewModel
|
return this.View(model);
|
||||||
{
|
}
|
||||||
IdStyle = style.IdStyle,
|
|
||||||
Libelle = style.Libelle,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Methode POST pour supprimer un style.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Le style a supprimer.</param>
|
||||||
|
/// <returns>Redirige vers la page d'index d'admin style.</returns>
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Delete(StyleDeleteViewModel model)
|
||||||
|
{
|
||||||
|
var style = this.styleRepository.Find(model.IdStyle);
|
||||||
|
|
||||||
|
if (style != null)
|
||||||
|
{
|
||||||
|
this.styleRepository.Delete(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Affiche la vue d'edition d'un style existant.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">L'identifiant du style a editer.</param>
|
||||||
|
/// <returns>La vue d'edition ou une redirection vers l'index si le style n'existe pas.</returns>
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Edit(int id)
|
||||||
|
{
|
||||||
|
var style = this.styleRepository.Find(id);
|
||||||
|
|
||||||
|
if (style == null || style.IdStyle == 0)
|
||||||
|
{
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
var model = new StyleEditViewModel
|
||||||
|
{
|
||||||
|
IdStyle = style.IdStyle,
|
||||||
|
Libelle = style.Libelle,
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.View(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Met a jour un style existant.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model">Donnees du style a modifier.</param>
|
||||||
|
/// <returns>Redirige vers la page d'index d'admin style.</returns>
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Edit(StyleEditViewModel model)
|
||||||
|
{
|
||||||
|
if (!this.ModelState.IsValid)
|
||||||
|
{
|
||||||
return this.View(model);
|
return this.View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var style = this.styleRepository.Find(model.IdStyle);
|
||||||
|
if (style == null)
|
||||||
|
{
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
style.Libelle = model.Libelle;
|
||||||
|
this.styleRepository.Update(style);
|
||||||
|
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,6 +170,11 @@ public class TitreController : Controller
|
|||||||
{
|
{
|
||||||
var titre = this.titreRepository.Find(id);
|
var titre = this.titreRepository.Find(id);
|
||||||
|
|
||||||
|
if (titre == null)
|
||||||
|
{
|
||||||
|
return this.RedirectToAction("Index");
|
||||||
|
}
|
||||||
|
|
||||||
var model = new AdminTitreDelete
|
var model = new AdminTitreDelete
|
||||||
{
|
{
|
||||||
Id = titre.IdTitre,
|
Id = titre.IdTitre,
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Artiste
|
||||||
|
{
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ViewModel qui sert à la création d'un artiste.
|
||||||
|
/// </summary>
|
||||||
|
public class ArtisteCreateViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Nom de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string Nom { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Biographie de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
public string Biographie { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Artiste
|
||||||
|
{
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Permet d'éditer un Artiste.
|
||||||
|
/// </summary>
|
||||||
|
public class ArtisteEditViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Nom de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string Nom { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Biographie de l'artiste.
|
||||||
|
/// </summary>
|
||||||
|
public string Biographie { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||||
{
|
{
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ViewModel pour la création d'un style en administration.
|
/// ViewModel pour la création d'un style en administration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -12,6 +14,7 @@ namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Obtient ou définit le libellé du style.
|
/// Obtient ou définit le libellé du style.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Required]
|
||||||
public string Libelle { get; set; }
|
public string Libelle { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,19 +4,22 @@
|
|||||||
|
|
||||||
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
namespace Webzine.WebApplication.Areas.Administration.ViewModels.Style
|
||||||
{
|
{
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ViewModel pour la modification d'un style en administration.
|
/// ViewModel pour la modification d'un style en administration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StyleEditViewModel
|
public class StyleEditViewModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Obtient ou définit le libellé du style.
|
/// Obtient ou definit l'identifiant du style.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IdStyle { get; set; }
|
public int IdStyle { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Obtient ou définit le libellé du style.
|
/// Obtient ou definit le libelle du style.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Required]
|
||||||
public string Libelle { get; set; }
|
public string Libelle { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,41 @@
|
|||||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.AdminArtisteForm
|
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.ArtisteCreateViewModel
|
||||||
|
|
||||||
<h1>Créer un artiste</h1>
|
<h1>Créer un artiste</h1>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
<form asp-action="Create" method="post">
|
<form asp-action="Create" method="post">
|
||||||
|
<div class="container">
|
||||||
|
<!-- ARTISTE -->
|
||||||
|
<div class="row mb-3">
|
||||||
|
<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>
|
||||||
|
|
||||||
<partial name="_Form" />
|
<!-- BIOGRAPHIE -->
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label class="col-md-3 col-form-label">Biographie</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<textarea asp-for="Biographie" class="form-control" rows="5"></textarea>
|
||||||
|
</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>
|
||||||
</form>
|
</form>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.AdminArtisteForm
|
@model Webzine.Entity.Artiste
|
||||||
|
|
||||||
<h1>Editer un artiste</h1>
|
<h1>Editer un artiste</h1>
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<form asp-action="Edit" method="post">
|
<form asp-action="Edit" method="post">
|
||||||
|
|
||||||
<input type="hidden" asp-for="Id"/>
|
<input type="hidden" asp-for="IdArtiste"/>
|
||||||
|
|
||||||
<partial name="_Form" />
|
<partial name="_Form" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.Artiste.AdminArtisteForm
|
@model Webzine.Entity.Artiste
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- ARTISTE -->
|
<!-- ARTISTE -->
|
||||||
@@ -17,8 +17,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- BOUTONS -->
|
<!-- BOUTONS -->
|
||||||
<div class="row mt-4">
|
<div class="row mt-4">
|
||||||
<div class="col-md-9 offset-md-3">
|
<div class="col-md-9 offset-md-3">
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
{
|
{
|
||||||
<tr class="align-middle">
|
<tr class="align-middle">
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="Details" asp-controller="Titre" asp-route-id="@commentaire.Titre.IdTitre">
|
<a asp-controller="Titre" asp-action="Index" asp-route-id="@commentaire.Titre.IdTitre">
|
||||||
@commentaire.Titre.Libelle
|
@commentaire.Titre.Libelle
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
@model Webzine.WebApplication.Areas.Administration.ViewModels.DashboardViewModel
|
@using Webzine.Business.Contracts.Dto
|
||||||
|
@model DashboardDTO
|
||||||
|
|
||||||
<h1 class="mb-4">Tableau de bord</h1>
|
<h1 class="mb-4">Tableau de bord</h1>
|
||||||
|
|
||||||
@@ -94,7 +95,7 @@
|
|||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<a asp-area=""
|
<a asp-area=""
|
||||||
asp-controller="Titre"
|
asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@Model.IdMusiqueLaPlusJouee">
|
asp-route-id="@Model.IdMusiqueLaPlusJouee">
|
||||||
<div class="ratio ratio-4x3">
|
<div class="ratio ratio-4x3">
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ namespace Webzine.WebApplication.Configuration;
|
|||||||
public enum SeederType
|
public enum SeederType
|
||||||
{
|
{
|
||||||
Local,
|
Local,
|
||||||
Spotify
|
Spotify,
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RepositoryType
|
public enum RepositoryType
|
||||||
{
|
{
|
||||||
Local,
|
Local,
|
||||||
Db
|
Db,
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,6 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="nom">Le nom de l'artiste à rechercher, formaté en kebab-case (ex: "fatal-bazooka").</param>
|
/// <param name="nom">Le nom de l'artiste à rechercher, formaté en kebab-case (ex: "fatal-bazooka").</param>
|
||||||
/// <returns>La vue de l'artiste avec son ViewModel, ou une redirection vers l'accueil si le nom est vide, ou une erreur 404 si l'artiste n'est pas trouvé.</returns>
|
/// <returns>La vue de l'artiste avec son ViewModel, ou une redirection vers l'accueil si le nom est vide, ou une erreur 404 si l'artiste n'est pas trouvé.</returns>
|
||||||
[HttpGet("/artiste/{nom}")]
|
|
||||||
public IActionResult Index(string nom)
|
public IActionResult Index(string nom)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom);
|
this.logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// Affichage de la page Recherche depuis le header de l'app.
|
/// Affichage de la page Recherche depuis le header de l'app.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mot">Nom d'artiste ou de titre.</param>
|
/// <param name="mot">Nom d'artiste ou de titre.</param>
|
||||||
/// <returns>Page de recherche avec les résultats.</returns>
|
/// <returns>Page de recherche avec les r<EFBFBD>sultats.</returns>
|
||||||
public IActionResult Index(string mot)
|
public IActionResult Index(string mot)
|
||||||
{
|
{
|
||||||
// Logger la recherche.
|
// Logger la recherche.
|
||||||
@@ -41,7 +41,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
// Recherche des artistes.
|
// Recherche des artistes.
|
||||||
var artistes = this.artisteRepository.Search(mot);
|
var artistes = this.artisteRepository.Search(mot);
|
||||||
|
|
||||||
// Paramètres a retourner à la vue.
|
// Param<EFBFBD>tres a retourner <EFBFBD> la vue.
|
||||||
var vm = new RechercheIndexViewModel
|
var vm = new RechercheIndexViewModel
|
||||||
{
|
{
|
||||||
Mot = mot,
|
Mot = mot,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// affichage des details, filtrage par style,
|
/// affichage des details, filtrage par style,
|
||||||
/// ajout de likes, commentaires et recherche.
|
/// ajout de likes, commentaires et recherche.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("titre")]
|
|
||||||
public class TitreController : Controller
|
public class TitreController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<TitreController> logger;
|
private readonly ILogger<TitreController> logger;
|
||||||
@@ -40,8 +39,8 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Identifiant du titre.</param>
|
/// <param name="id">Identifiant du titre.</param>
|
||||||
/// <returns>Vue des details ou 404 si introuvable.</returns>
|
/// <returns>Vue des details ou 404 si introuvable.</returns>
|
||||||
[HttpGet("{id}")]
|
|
||||||
public IActionResult Details(int id)
|
public IActionResult Index(int id)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Demande d'affichage du detail pour le titre ID {Id}.", id);
|
this.logger.LogInformation("Demande d'affichage du detail pour le titre ID {Id}.", id);
|
||||||
|
|
||||||
@@ -82,7 +81,6 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="style">Nom du style musical.</param>
|
/// <param name="style">Nom du style musical.</param>
|
||||||
/// <returns>Vue contenant la liste filtree.</returns>
|
/// <returns>Vue contenant la liste filtree.</returns>
|
||||||
[HttpGet("style/{style}")]
|
|
||||||
public IActionResult Style(string style)
|
public IActionResult Style(string style)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Recherche des titres pour le style : {Style}.", style);
|
this.logger.LogInformation("Recherche des titres pour le style : {Style}.", style);
|
||||||
@@ -103,7 +101,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">Modele contenant l'identifiant du titre.</param>
|
/// <param name="model">Modele contenant l'identifiant du titre.</param>
|
||||||
/// <returns>Redirection vers la page detail.</returns>
|
/// <returns>Redirection vers la page detail.</returns>
|
||||||
[HttpPost("like")]
|
[HttpPost]
|
||||||
public IActionResult Like(TitreLike model)
|
public IActionResult Like(TitreLike model)
|
||||||
{
|
{
|
||||||
this.logger.LogInformation("Ajout d'un like pour le titre ID {Id}.", model.IdTitre);
|
this.logger.LogInformation("Ajout d'un like pour le titre ID {Id}.", model.IdTitre);
|
||||||
@@ -126,7 +124,7 @@ namespace Webzine.WebApplication.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="model">Donnees du commentaire.</param>
|
/// <param name="model">Donnees du commentaire.</param>
|
||||||
/// <returns>Redirection vers la page detail.</returns>
|
/// <returns>Redirection vers la page detail.</returns>
|
||||||
[HttpPost("comment")]
|
[HttpPost]
|
||||||
public IActionResult Comment(TitreComment model)
|
public IActionResult Comment(TitreComment model)
|
||||||
{
|
{
|
||||||
if (!this.ModelState.IsValid)
|
if (!this.ModelState.IsValid)
|
||||||
|
|||||||
@@ -7,6 +7,41 @@ public static class RouteConfiguration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void MapCustomRoutes(this IEndpointRouteBuilder endpoints)
|
public static void MapCustomRoutes(this IEndpointRouteBuilder endpoints)
|
||||||
{
|
{
|
||||||
|
// ----------- TITRE -----------
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: "TitreStyle",
|
||||||
|
pattern: "titres/style/{style}",
|
||||||
|
defaults: new { controller = "Titre", action = "Style" });
|
||||||
|
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: "TitreIndex",
|
||||||
|
pattern: "titre/{id}",
|
||||||
|
defaults: new { controller = "Titre", action = "Index" });
|
||||||
|
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: "ArtisteIndex",
|
||||||
|
pattern: "artiste/{nom}",
|
||||||
|
defaults: new { controller = "Artiste", action = "Index" });
|
||||||
|
|
||||||
|
|
||||||
|
// ----------- ADMIN -----------
|
||||||
|
|
||||||
|
var adminRoutes = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "artistes", "Artiste" }, { "commentaires", "Commentaire" }, { "styles", "Style" }, { "titres", "Titre" },
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var route in adminRoutes)
|
||||||
|
{
|
||||||
|
endpoints.MapControllerRoute(
|
||||||
|
name: $"Admin{route.Value}Index",
|
||||||
|
pattern: $"administration/{route.Key}",
|
||||||
|
defaults: new { area = "Administration", controller = route.Value, action = "Index" });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --- AUTRE PROUTES ---
|
||||||
|
|
||||||
endpoints.MapControllerRoute(
|
endpoints.MapControllerRoute(
|
||||||
name: "areas",
|
name: "areas",
|
||||||
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ try
|
|||||||
// En fonction de la configuration, utilise soit les repositories basés sur une base de données, soit les repositories basés sur des listes locales.
|
// En fonction de la configuration, utilise soit les repositories basés sur une base de données, soit les repositories basés sur des listes locales.
|
||||||
var repositoryType = builder.Configuration.GetValue<RepositoryType>("Repository");
|
var repositoryType = builder.Configuration.GetValue<RepositoryType>("Repository");
|
||||||
var seederType = builder.Configuration.GetValue<SeederType>("Seeder");
|
var seederType = builder.Configuration.GetValue<SeederType>("Seeder");
|
||||||
|
var shouldSeed = args.Contains("--seed");
|
||||||
if (repositoryType == RepositoryType.Db)
|
if (repositoryType == RepositoryType.Db)
|
||||||
{
|
{
|
||||||
if (builder.Environment.IsProduction())
|
if (builder.Environment.IsProduction())
|
||||||
@@ -68,6 +69,7 @@ try
|
|||||||
builder.Services.AddSingleton<InMemoryDataStore>();
|
builder.Services.AddSingleton<InMemoryDataStore>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.Services.AddScoped<IDashboardService, DashboardService>();
|
||||||
builder.Services.AddScoped<ITitreAdminService, TitreAdminService>();
|
builder.Services.AddScoped<ITitreAdminService, TitreAdminService>();
|
||||||
|
|
||||||
// https://learn.microsoft.com/fr-fr/aspnet/core/performance/response-compression?view=aspnetcore-10.0#configuration
|
// https://learn.microsoft.com/fr-fr/aspnet/core/performance/response-compression?view=aspnetcore-10.0#configuration
|
||||||
@@ -81,10 +83,23 @@ try
|
|||||||
using (var scope = app.Services.CreateScope())
|
using (var scope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var db = scope.ServiceProvider.GetRequiredService<WebzineDbContext>();
|
var db = scope.ServiceProvider.GetRequiredService<WebzineDbContext>();
|
||||||
db.Database.EnsureDeleted();
|
|
||||||
db.Database.EnsureCreated();
|
db.Database.EnsureCreated();
|
||||||
var repo = scope.ServiceProvider.GetRequiredService<DbEntityRepository>();
|
|
||||||
repo.SeedBaseDeDonnees();
|
if (shouldSeed)
|
||||||
|
{
|
||||||
|
db.Database.EnsureDeleted();
|
||||||
|
db.Database.EnsureCreated();
|
||||||
|
var repo = scope.ServiceProvider.GetRequiredService<DbEntityRepository>();
|
||||||
|
|
||||||
|
if (seederType == SeederType.Local)
|
||||||
|
{
|
||||||
|
repo.SeedBaseDeDonnees();
|
||||||
|
}
|
||||||
|
else if (seederType == SeederType.Spotify)
|
||||||
|
{
|
||||||
|
// Seed à l'aide de l'API Spotify.
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -18,6 +18,26 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"http-seed": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "http://localhost:5038",
|
||||||
|
"commandLineArgs": "--seed",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https-seed": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7095;http://localhost:5038",
|
||||||
|
"commandLineArgs": "--seed",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
@titre.Artiste.Nom
|
@titre.Artiste.Nom
|
||||||
</a>
|
</a>
|
||||||
-
|
-
|
||||||
<a asp-action="Details"
|
<a asp-action="Index"
|
||||||
asp-controller="Titre"
|
asp-controller="Titre"
|
||||||
asp-route-id="@titre.IdTitre">
|
asp-route-id="@titre.IdTitre">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
<div class="d-flex flex-wrap align-items-center gap-3">
|
<div class="d-flex flex-wrap align-items-center gap-3">
|
||||||
<a asp-action="Details"
|
<a asp-action="Index"
|
||||||
asp-controller="Titre"
|
asp-controller="Titre"
|
||||||
asp-route-id="@titre.IdTitre"
|
asp-route-id="@titre.IdTitre"
|
||||||
class="btn btn-primary btn-sm">
|
class="btn btn-primary btn-sm">
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
<img class="card-img-top" src="@titre.UrlJaquette" alt="@titre.Album" loading="lazy" />
|
<img class="card-img-top" src="@titre.UrlJaquette" alt="@titre.Album" loading="lazy" />
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<a asp-controller="Titre" asp-action="Details" asp-route-id="@titre.IdTitre" class="card-link">
|
<a asp-controller="Titre" asp-action="Index" asp-route-id="@titre.IdTitre" class="card-link">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
</a>
|
</a>
|
||||||
<br />
|
<br />
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ else
|
|||||||
<td class="text-secondary font-monospace">@dureeFormatee</td>
|
<td class="text-secondary font-monospace">@dureeFormatee</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-controller="Titre"
|
<a asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@titre.IdTitre"
|
asp-route-id="@titre.IdTitre"
|
||||||
class="text-primary">
|
class="text-primary">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
@if (!Model.Artistes.Any())
|
@if (!Model.Artistes.Any())
|
||||||
{
|
{
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<p>Aucun artiste n'a été trouvé.</p>
|
<p>Aucun artiste n'a été trouvé.</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
@if (!Model.Titres.Any())
|
@if (!Model.Titres.Any())
|
||||||
{
|
{
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<p>Aucun titre n'a été trouvé.</p>
|
<p>Aucun titre n'a été trouvé.</p>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
{
|
{
|
||||||
<div class="d-flex align-items-start my-3">
|
<div class="d-flex align-items-start my-3">
|
||||||
<a asp-controller="Titre"
|
<a asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@titre.IdTitre"
|
asp-route-id="@titre.IdTitre"
|
||||||
class="me-3 text-black">
|
class="me-3 text-black">
|
||||||
<img src="@titre.UrlJaquette" alt="@titre.Libelle" width="70" height="70" class="object-fit-cover" loading="lazy" />
|
<img src="@titre.UrlJaquette" alt="@titre.Libelle" width="70" height="70" class="object-fit-cover" loading="lazy" />
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
</a>
|
</a>
|
||||||
-
|
-
|
||||||
<a asp-controller="Titre"
|
<a asp-controller="Titre"
|
||||||
asp-action="Details"
|
asp-action="Index"
|
||||||
asp-route-id="@titre.IdTitre">
|
asp-route-id="@titre.IdTitre">
|
||||||
@titre.Libelle
|
@titre.Libelle
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- Barre de recherche -->
|
<!-- Barre de recherche -->
|
||||||
<form class="d-flex" asp-controller="Recherche" asp-action="Index" method="get">
|
<form class="d-flex" asp-area="" asp-controller="Recherche" asp-action="Index" method="get">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="form-outline">
|
<div class="form-outline">
|
||||||
<input class="form-control me-2"
|
<input class="form-control me-2"
|
||||||
|
|||||||
@@ -3,5 +3,7 @@
|
|||||||
image: webzine.webapplication
|
image: webzine.webapplication
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Webzine.WebApplication/Dockerfile
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
environment:
|
||||||
|
- ConnectionStrings__PostGreSQLConnection=${PGSQL_CONNECTION}
|
||||||
@@ -131,7 +131,7 @@ info "── Titre – Par style ───────────────
|
|||||||
STYLES=("Rock" "Pop" "Rap" "Jazz" "Metal" "Electronic" "Hip-Hop" "Soul" "Funk")
|
STYLES=("Rock" "Pop" "Rap" "Jazz" "Metal" "Electronic" "Hip-Hop" "Soul" "Funk")
|
||||||
for STYLE in "${STYLES[@]}"; do
|
for STYLE in "${STYLES[@]}"; do
|
||||||
ENCODE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$STYLE'))" 2>/dev/null || echo "$STYLE")
|
ENCODE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$STYLE'))" 2>/dev/null || echo "$STYLE")
|
||||||
verifier_endpoint GET "$BASE_URL/titre/style/$ENCODE" "GET /titre/style/$STYLE"
|
verifier_endpoint GET "$BASE_URL/titres/style/$ENCODE" "GET /titres/style/$STYLE"
|
||||||
done
|
done
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
@@ -160,26 +160,26 @@ verifier_endpoint GET "$BASE_URL/Administration/Dashboard" "GET /A
|
|||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Artiste ──────────────────────────────"
|
info "── Administration – Artiste ──────────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste" "GET /Administration/Artiste (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Artistes" "GET /Administration/Artistes (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Create" "GET /Administration/Artiste/Create"
|
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Create" "GET /Administration/Artiste/Create"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Edit/1" "GET /Administration/Artiste/Edit/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Edit/1" "GET /Administration/Artiste/Edit/1"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Delete/1" "GET /Administration/Artiste/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Artiste/Delete/1" "GET /Administration/Artiste/Delete/1"
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Commentaire ──────────────────────────"
|
info "── Administration – Commentaire ──────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Commentaire" "GET /Administration/Commentaire (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Commentaires" "GET /Administration/Commentaires (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Commentaire/Delete/1" "GET /Administration/Commentaire/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Commentaire/Delete/1" "GET /Administration/Commentaire/Delete/1"
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Style ────────────────────────────────"
|
info "── Administration – Style ────────────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style" "GET /Administration/Style (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Styles" "GET /Administration/Styles (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Create" "GET /Administration/Style/Create"
|
verifier_endpoint GET "$BASE_URL/Administration/Style/Create" "GET /Administration/Style/Create"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Edit/1" "GET /Administration/Style/Edit/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Style/Edit/1" "GET /Administration/Style/Edit/1"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Style/Delete/1" "GET /Administration/Style/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Style/Delete/1" "GET /Administration/Style/Delete/1"
|
||||||
|
|
||||||
log ""
|
log ""
|
||||||
info "── Administration – Titre ────────────────────────────────"
|
info "── Administration – Titre ────────────────────────────────"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre" "GET /Administration/Titre (liste)"
|
verifier_endpoint GET "$BASE_URL/Administration/Titres" "GET /Administration/Titres (liste)"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Create" "GET /Administration/Titre/Create"
|
verifier_endpoint GET "$BASE_URL/Administration/Titre/Create" "GET /Administration/Titre/Create"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Edit/1" "GET /Administration/Titre/Edit/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Titre/Edit/1" "GET /Administration/Titre/Edit/1"
|
||||||
verifier_endpoint GET "$BASE_URL/Administration/Titre/Delete/1" "GET /Administration/Titre/Delete/1"
|
verifier_endpoint GET "$BASE_URL/Administration/Titre/Delete/1" "GET /Administration/Titre/Delete/1"
|
||||||
|
|||||||
Reference in New Issue
Block a user