diff --git a/Webzine.Documentation/Rapport/equipe 1 - rapport.md b/Webzine.Documentation/Rapport/equipe 1 - rapport.md index d713c03..8236725 100644 --- a/Webzine.Documentation/Rapport/equipe 1 - rapport.md +++ b/Webzine.Documentation/Rapport/equipe 1 - rapport.md @@ -1,6 +1,14 @@ **Loïc Masi** : + +04/03 : - Création de 'AccueilController' - Création de la fonction Index() -> afficher l'accueil du webzine - Ajout de la vue 'Views/Accueil/Index.cshtml' - Mise en place d'un Header dans 'Views/Shared/_Header.cshtml' -- Mise en place de la Sidebar dans 'Views/Shared/_Sidebar.cshtml' \ No newline at end of file +- Mise en place de la Sidebar dans 'Views/Shared/_Sidebar.cshtml' + +05/03 : +- Mise en place de fausse données dans 'Webzine.Repository' à l'aide de Faker +- Ajout du ViewModel pour afficher les informations nécessaire sur la page d'accueil +- Adaptation de quelques éléments sur la page (Bootstrap) +- Mise en place du parametrage du nombre d'elements a afficher sur la page dans appsettings \ No newline at end of file diff --git a/Webzine.Entity/Fixtures/ArtisteFactory.cs b/Webzine.Entity/Fixtures/ArtisteFactory.cs new file mode 100644 index 0000000..e9af87b --- /dev/null +++ b/Webzine.Entity/Fixtures/ArtisteFactory.cs @@ -0,0 +1,54 @@ +using Bogus; + +namespace Webzine.Entity.Fixtures +{ + /// + /// Factory pour générer des artistes avec des titres associés, à l'aide de la bibliothèque Bogus. + /// + /// + public class ArtisteFactory + { + /// + /// Récupère un artiste par son nom, en générant des données fictives pour ses titres associés. + /// + /// + /// + public static Artiste SeedArtisteByName(string nom) + { + // On définit nos albums "bouchonnés" + var albumsData = new[] + { + new { Nom = "Bohemian Rhapsody", Image = "https://upload.wikimedia.org/wikipedia/en/9/9f/Bohemian_Rhapsody.png" }, + new { Nom = "Born This Way", Image = "https://static.wikia.nocookie.net/ladygaga/images/2/2d/BornThisWay-DeluxeEdition.jpg/revision/latest/scale-to-width-down/3500?cb=20111120030308" } + }; + + var faker = new Bogus.Faker("fr"); + var tousLesTitres = new List(); + + // Pour chaque album, on génère un paquet de titres + foreach (var album in albumsData) + { + var nombreDeTitres = faker.Random.Number(3, 6); + + var titresDeLalbum = new Faker("fr") + .RuleFor(t => t.IdTitre, f => f.IndexFaker + 1 + tousLesTitres.Count) + .RuleFor(t => t.UrlJaquette, _ => album.Image) + .RuleFor(t => t.Album, _ => album.Nom) + .RuleFor(t => t.Duree, f => f.Random.Number(90, 180)) + .RuleFor(t => t.Libelle, f => f.Music.Genre() + " - " + f.Commerce.ProductName()) + .Generate(nombreDeTitres); + + tousLesTitres.AddRange(titresDeLalbum); + } + + // On crée l'artiste final + var artisteFaker = new Faker("fr") + .RuleFor(a => a.IdArtiste, f => f.IndexFaker + 1) + .RuleFor(a => a.Nom, _ => nom) + .RuleFor(a => a.Biographie, f => f.Lorem.Paragraphs(2)) + .RuleFor(a => a.Titres, _ => tousLesTitres); + + return artisteFaker.Generate(); + } + } +} \ No newline at end of file diff --git a/Webzine.Entity/Webzine.Entity.csproj b/Webzine.Entity/Webzine.Entity.csproj index 33c0658..06e46f1 100644 --- a/Webzine.Entity/Webzine.Entity.csproj +++ b/Webzine.Entity/Webzine.Entity.csproj @@ -7,6 +7,7 @@ + diff --git a/Webzine.Repository/Fake/TitreFactory.cs b/Webzine.Repository/Fake/TitreFactory.cs new file mode 100644 index 0000000..f92bf9d --- /dev/null +++ b/Webzine.Repository/Fake/TitreFactory.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using Faker; +using Webzine.Entity; + +namespace Webzine.Repository.Fake +{ + public static class FakeDataFactory + { + //https://cdn-images.dzcdn.net/images/cover/311bba0fc112d15f72c8b5a65f0456c1/1900x1900-000000-80-0-0.jpg", + public static List GetArtistes(int count = 10) + { + var artistes = new List(); + + for (int i = 1; i <= count; i++) + { + artistes.Add(new Artiste + { + IdArtiste = i, + Nom = Name.FullName(), + Biographie = Lorem.Paragraph(), + Titres = new List() + }); + } + + return artistes; + } + + public static List GetTitres(int count = 40) + { + var artistes = GetArtistes(); + var titres = new List(); + + for (int i = 1; i <= count; i++) + { + var artiste = artistes[RandomNumber.Next(0, artistes.Count - 1)]; + + var titre = new Titre + { + IdTitre = i, + IdArtiste = artiste.IdArtiste, + Artiste = artiste, + Libelle = Lorem.Sentence(3), + Chronique = Lorem.Paragraph(), + DateCreation = DateTime.Now.AddDays(-RandomNumber.Next(1, 100)), + DateSortie = DateTime.Now.AddYears(-RandomNumber.Next(1, 20)), + Duree = RandomNumber.Next(120, 420), + UrlJaquette = "https://picsum.photos/300", + UrlEcoute = Internet.Url(), + NbLectures = RandomNumber.Next(0, 500), + NbLikes = RandomNumber.Next(0, 200), + Album = Lorem.Sentence(2), + Commentaires = new List() + }; + + titres.Add(titre); + artiste.Titres.Add(titre); + } + + return titres; + } + } +} diff --git a/Webzine.Repository/Webzine.Repository.csproj b/Webzine.Repository/Webzine.Repository.csproj index c8bc3e1..cc38234 100644 --- a/Webzine.Repository/Webzine.Repository.csproj +++ b/Webzine.Repository/Webzine.Repository.csproj @@ -24,13 +24,6 @@ - - - - - - ..\..\..\..\..\..\..\.nuget\packages\microsoft.testing.platform\2.0.1\lib\net9.0\Microsoft.Testing.Platform.dll - diff --git a/Webzine.WebApplication/Areas/Administration/Controllers/CommentairesController.cs b/Webzine.WebApplication/Areas/Administration/Controllers/CommentairesController.cs new file mode 100644 index 0000000..820cb0f --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/Controllers/CommentairesController.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Webzine.Entity; +using Webzine.Entity.Fixtures; +using Webzine.WebApplication.Areas.Administration.ViewModels.Commentaire; + +namespace Webzine.WebApplication.Areas.Administration.Controllers +{ + [Area("Administration")] + public class CommentaireController : Controller + { + private readonly ILogger _logger; + private readonly List _commentaires; + /// + /// Initialise une nouvelle instance du . + /// Les données sont générées dynamiquement via . + /// + /// Service de journalisation injecté. + public CommentaireController(ILogger logger) + { + _logger = logger; + + _logger.LogInformation("Initialisation du contrôleur CommentaireController."); + + var factory = new DataFactory(); + + var _artistes = factory.GenerateArtists(10); + var _styles = factory.GenerateStyles(10); + var _titres = factory.GenerateTitres(30, _artistes, _styles); + + _commentaires = factory.GenerateCommentaires(50, _titres); + + _logger.LogInformation("Données fictives générées avec succès."); + } + + // GET: Administration/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: Administration/Commentaires/Delete/5 + public ActionResult Delete(int id) + { + var commentaire = _commentaires + .FirstOrDefault(c => c.IdCommentaire == id); + + if (commentaire == null) + return NotFound(); + + var vm = new CommentaireDeleteViewModel + { + IdCommentaire = commentaire.IdCommentaire, + Auteur = commentaire.Auteur, + Contenu = commentaire.Contenu, + DateCreation = commentaire.DateCreation, + TitreLibelle = commentaire.Titre?.Libelle + }; + + return View(vm); + } + + // POST: Administration/Commentaires/Delete/5 + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult Delete(int id, CommentaireDeleteViewModel model) + { + try + { + return RedirectToAction(); + } + catch (Exception e) + { + // Log de l'erreur + Console.WriteLine(e); + return View(model); + } + } + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Accueil/AccueilIndexViewModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Accueil/AccueilIndexViewModel.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Accueil/AccueilIndexViewModel.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/ArtisteModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/ArtisteModel.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/ArtisteModel.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireDeleteViewModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireDeleteViewModel.cs new file mode 100644 index 0000000..9b6b8c6 --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireDeleteViewModel.cs @@ -0,0 +1,14 @@ +namespace Webzine.WebApplication.Areas.Administration.ViewModels.Commentaire; + +public class CommentaireDeleteViewModel +{ + public int IdCommentaire { get; set; } + + public string? Auteur { get; set; } + + public string? Contenu { get; set; } + + public DateTime DateCreation { get; set; } + + public string? TitreLibelle { get; set; } +} \ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireViewModel.cs b/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireViewModel.cs new file mode 100644 index 0000000..3ce7115 --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/ViewModels/Commentaire/CommentaireViewModel.cs @@ -0,0 +1,21 @@ +// +// Copyright (c) Webzine. All rights reserved. +// + + +// +// Copyright (c) Webzine. All rights reserved. +// +namespace Webzine.WebApplication.Areas.Administration.ViewModels.Commentaire +{ + /// + /// 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/Areas/Administration/Views/Commentaire/Delete.cshtml b/Webzine.WebApplication/Areas/Administration/Views/Commentaire/Delete.cshtml new file mode 100644 index 0000000..f9fa126 --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/Views/Commentaire/Delete.cshtml @@ -0,0 +1,42 @@ +@model Webzine.WebApplication.Areas.Administration.ViewModels.Commentaire.CommentaireDeleteViewModel + +@{ + ViewData["Title"] = "Supprimer un commentaire"; +} + +
+ +

Supprimer un commentaire

+
+ +

+ Êtes-vous sûr de vouloir supprimer le commentaire suivant ? +

+ +
+

@Model.Contenu

+ +
+ — @Model.Auteur + le @Model.DateCreation.ToString("dd/MM/yyyy HH:mm:ss") + sur @Model.TitreLibelle +
+
+ +
+ + + +
+ +
+
+ + + Retour à l'administration des commentaires + + +
\ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/Views/Commentaire/Index.cshtml b/Webzine.WebApplication/Areas/Administration/Views/Commentaire/Index.cshtml new file mode 100644 index 0000000..c8241d3 --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/Views/Commentaire/Index.cshtml @@ -0,0 +1,48 @@ +@model Webzine.WebApplication.Areas.Administration.ViewModels.Commentaire.CommentaireViewModel + +@{ + ViewData["Title"] = "Commentaires"; +} + + +
+

Commentaires

+ +
+ + + + + + + + + + + + @foreach (Webzine.Entity.Commentaire commentaire in Model.Commentaires) + { + + + + + + + + } + +
TitreAuteurCommentaireDate de créationActions
+ @commentaire.Titre.Libelle + + @commentaire.Auteur + + @commentaire.Contenu + + @commentaire.DateCreation.ToString("dd/MM/yyyy HH:mm:ss") + + + + +
+
+
\ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/Views/Commentaires/Index.cshtml b/Webzine.WebApplication/Areas/Administration/Views/Commentaires/Index.cshtml index fadf546..5f28270 100644 --- a/Webzine.WebApplication/Areas/Administration/Views/Commentaires/Index.cshtml +++ b/Webzine.WebApplication/Areas/Administration/Views/Commentaires/Index.cshtml @@ -1,89 +1 @@ -@using Webzine.WebApplication.ViewModels -@using Webzine.Entity -@model CommentaireViewModel - -@{ - ViewData["Title"] = "Commentaires"; -} - - - -

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() - -
-
-
+ \ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/Views/Shared/_Header.cshtml b/Webzine.WebApplication/Areas/Administration/Views/Shared/_Header.cshtml new file mode 100644 index 0000000..9a66f6e --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/Views/Shared/_Header.cshtml @@ -0,0 +1,58 @@ +@* + For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 +*@ +@{ +} +
+ +
\ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/Views/Shared/_Layout.cshtml b/Webzine.WebApplication/Areas/Administration/Views/Shared/_Layout.cshtml index d22a349..78ef447 100644 --- a/Webzine.WebApplication/Areas/Administration/Views/Shared/_Layout.cshtml +++ b/Webzine.WebApplication/Areas/Administration/Views/Shared/_Layout.cshtml @@ -14,14 +14,7 @@ -
- @await Html.PartialAsync("_Header") -
-
- @RenderBody() -
- @await Html.PartialAsync("_Sidebar") -
-
+ @await Html.PartialAsync("_Header") + @RenderBody() \ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/Views/_ViewImports.cshtml b/Webzine.WebApplication/Areas/Administration/Views/_ViewImports.cshtml new file mode 100644 index 0000000..505b08b --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/Views/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@* Permet de factoriser les imports de tag helpers *@ +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/Webzine.WebApplication/Areas/Administration/Views/_ViewStart.cshtml b/Webzine.WebApplication/Areas/Administration/Views/_ViewStart.cshtml new file mode 100644 index 0000000..d641c67 --- /dev/null +++ b/Webzine.WebApplication/Areas/Administration/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} \ No newline at end of file diff --git a/Webzine.WebApplication/Controllers/AccueilController.cs b/Webzine.WebApplication/Controllers/AccueilController.cs index 32e2e49..7e18194 100644 --- a/Webzine.WebApplication/Controllers/AccueilController.cs +++ b/Webzine.WebApplication/Controllers/AccueilController.cs @@ -1,83 +1,44 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; +using Webzine.Repository.Fake; +using Webzine.WebApplication.ViewModels.Accueil; namespace Webzine.WebApplication.Controllers { public class AccueilController : Controller { + // Injection du logger via le constructeur + private readonly ILogger _logger; + private readonly IConfiguration _configuration; + + public AccueilController(ILogger logger, IConfiguration configuration) + { + _logger = logger; + _configuration = configuration; + } + // GET: AccueilController public ActionResult Index() { - return View(); - } + _logger.LogInformation("Arrivée sur la page d'accueil"); - // GET: AccueilController/Details/5 - public ActionResult Details(int id) - { - return View(); - } + var derniereChronique = _configuration.GetValue("Webzine:NombreDerniereChronique"); + var topTitres = _configuration.GetValue("Webzine:NombreDeTopTitres"); + var titres = FakeDataFactory.GetTitres(); - // GET: AccueilController/Create - public ActionResult Create() - { - return View(); - } - - // POST: AccueilController/Create - [HttpPost] - [ValidateAntiForgeryToken] - public ActionResult Create(IFormCollection collection) - { - try + var vm = new AccueilIndexViewModel { - return RedirectToAction(nameof(Index)); - } - catch - { - return View(); - } - } + DerniersTitres = titres + .OrderByDescending(t => t.DateCreation) + .Take(derniereChronique) + .ToList(), - // GET: AccueilController/Edit/5 - public ActionResult Edit(int id) - { - return View(); - } + TopTitres = titres + .OrderByDescending(t => t.NbLikes) + .Take(topTitres) + .ToList() + }; - // POST: AccueilController/Edit/5 - [HttpPost] - [ValidateAntiForgeryToken] - public ActionResult Edit(int id, IFormCollection collection) - { - try - { - return RedirectToAction(nameof(Index)); - } - catch - { - return View(); - } - } - - // GET: AccueilController/Delete/5 - public ActionResult Delete(int id) - { - return View(); - } - - // POST: AccueilController/Delete/5 - [HttpPost] - [ValidateAntiForgeryToken] - public ActionResult Delete(int id, IFormCollection collection) - { - try - { - return RedirectToAction(nameof(Index)); - } - catch - { - return View(); - } + return View(vm); } } } diff --git a/Webzine.WebApplication/Controllers/ArtisteController.cs b/Webzine.WebApplication/Controllers/ArtisteController.cs new file mode 100644 index 0000000..0f5b91a --- /dev/null +++ b/Webzine.WebApplication/Controllers/ArtisteController.cs @@ -0,0 +1,54 @@ +using Microsoft.AspNetCore.Mvc; +using Webzine.Entity.Fixtures; +using Webzine.WebApplication.ViewModels; + +namespace Webzine.WebApplication.Controllers +{ + public class ArtisteController : Controller + { + // Injection du logger via le constructeur + private readonly ILogger _logger; + + public ArtisteController(ILogger logger) + { + _logger = logger; + } + + /// + /// Prend en paramètre le nom de l'artiste (ex: "fatal-bazooka"), utilise la factory pour trouver l'artiste correspondant, et affiche sa page dédiée. + /// + /// + /// + [HttpGet("/artiste/{nom}")] + public IActionResult Index(string nom) + { + _logger.LogInformation("Tentative d'accès à l'artiste avec le nom : {NomArtiste}", nom); + + if (string.IsNullOrEmpty(nom)) return RedirectToAction("Index", "Accueil"); + + // On transforme "fatal-bazooka" en "Fatal Bazooka" pour la factory + string nomPropre = System.Globalization.CultureInfo.CurrentCulture.TextInfo + .ToTitleCase(nom.Replace("-", " ")); + + // On appelle la factory pour obtenir l'artiste unique + var artiste = ArtisteFactory.SeedArtisteByName(nomPropre); + + if (artiste == null) + { + _logger.LogWarning("Artiste non trouvé pour le nom : {NomArtiste}", nomPropre); + return NotFound(); + } + + _logger.LogInformation("Artiste trouvé : {NomArtiste}", nom); + + // On remplit le ViewModel + var viewModel = new ArtisteModel + { + Artiste = artiste, + Titres = artiste.Titres + }; + + return View(viewModel); + } + } +} diff --git a/Webzine.WebApplication/Controllers/ContactController.cs b/Webzine.WebApplication/Controllers/ContactController.cs new file mode 100644 index 0000000..557e1fb --- /dev/null +++ b/Webzine.WebApplication/Controllers/ContactController.cs @@ -0,0 +1,15 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Webzine.WebApplication.Controllers +{ + /// + /// Controller pour la page contact. + /// + public class ContactController : Controller + { + public IActionResult Index() + { + return View(); + } + } +} diff --git a/Webzine.WebApplication/Controllers/TitreController.cs b/Webzine.WebApplication/Controllers/TitreController.cs index 9ea5db5..b89c757 100644 --- a/Webzine.WebApplication/Controllers/TitreController.cs +++ b/Webzine.WebApplication/Controllers/TitreController.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; using Webzine.Entity; using Webzine.Entity.Fixtures; -using Webzine.WebApplication.ViewsModels.Titre; +using Webzine.WebApplication.ViewModels.Titre; namespace Webzine.WebApplication.Controllers; diff --git a/Webzine.WebApplication/ViewModels/Accueil/AccueilIndexViewModel.cs b/Webzine.WebApplication/ViewModels/Accueil/AccueilIndexViewModel.cs new file mode 100644 index 0000000..8a163d1 --- /dev/null +++ b/Webzine.WebApplication/ViewModels/Accueil/AccueilIndexViewModel.cs @@ -0,0 +1,10 @@ +using Webzine.Entity; + +namespace Webzine.WebApplication.ViewModels.Accueil +{ + public class AccueilIndexViewModel + { + public List DerniersTitres { get; set; } = []; + public List TopTitres { get; set; } = []; + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/ViewModels/ArtisteModel.cs b/Webzine.WebApplication/ViewModels/ArtisteModel.cs new file mode 100644 index 0000000..c362cd9 --- /dev/null +++ b/Webzine.WebApplication/ViewModels/ArtisteModel.cs @@ -0,0 +1,17 @@ +using Webzine.Entity; + +namespace Webzine.WebApplication.ViewModels +{ + public class ArtisteModel + { + /// + /// Artiste dont on affiche les détails. + /// + public Artiste Artiste { get; set; } + + /// + /// Liste des titres de l'artiste. + /// + public List Titres { get; set; } + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/ViewsModels/Titre/TitreComment.cs b/Webzine.WebApplication/ViewModels/Titre/TitreComment.cs similarity index 86% rename from Webzine.WebApplication/ViewsModels/Titre/TitreComment.cs rename to Webzine.WebApplication/ViewModels/Titre/TitreComment.cs index 2301088..da0dc16 100644 --- a/Webzine.WebApplication/ViewsModels/Titre/TitreComment.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreComment.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Webzine.WebApplication.ViewsModels.Titre; +namespace Webzine.WebApplication.ViewModels.Titre; public class TitreComment { diff --git a/Webzine.WebApplication/ViewsModels/Titre/TitreContent.cs b/Webzine.WebApplication/ViewModels/Titre/TitreContent.cs similarity index 90% rename from Webzine.WebApplication/ViewsModels/Titre/TitreContent.cs rename to Webzine.WebApplication/ViewModels/Titre/TitreContent.cs index fd671c9..b1ee798 100644 --- a/Webzine.WebApplication/ViewsModels/Titre/TitreContent.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreContent.cs @@ -1,6 +1,6 @@ using Webzine.Entity; -namespace Webzine.WebApplication.ViewsModels.Titre; +namespace Webzine.WebApplication.ViewModels.Titre; public class TitreContent { diff --git a/Webzine.WebApplication/ViewsModels/Titre/TitreDetail.cs b/Webzine.WebApplication/ViewModels/Titre/TitreDetail.cs similarity index 70% rename from Webzine.WebApplication/ViewsModels/Titre/TitreDetail.cs rename to Webzine.WebApplication/ViewModels/Titre/TitreDetail.cs index 82f076b..c02a96f 100644 --- a/Webzine.WebApplication/ViewsModels/Titre/TitreDetail.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreDetail.cs @@ -1,4 +1,4 @@ -namespace Webzine.WebApplication.ViewsModels.Titre; +namespace Webzine.WebApplication.ViewModels.Titre; public class TitreDetail { diff --git a/Webzine.WebApplication/ViewsModels/Titre/TitreLike.cs b/Webzine.WebApplication/ViewModels/Titre/TitreLike.cs similarity index 55% rename from Webzine.WebApplication/ViewsModels/Titre/TitreLike.cs rename to Webzine.WebApplication/ViewModels/Titre/TitreLike.cs index b126e20..d13c460 100644 --- a/Webzine.WebApplication/ViewsModels/Titre/TitreLike.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreLike.cs @@ -1,4 +1,4 @@ -namespace Webzine.WebApplication.ViewsModels.Titre; +namespace Webzine.WebApplication.ViewModels.Titre; public class TitreLike { diff --git a/Webzine.WebApplication/ViewsModels/Titre/TitreStyle.cs b/Webzine.WebApplication/ViewModels/Titre/TitreStyle.cs similarity index 72% rename from Webzine.WebApplication/ViewsModels/Titre/TitreStyle.cs rename to Webzine.WebApplication/ViewModels/Titre/TitreStyle.cs index 72d2410..3ef9bba 100644 --- a/Webzine.WebApplication/ViewsModels/Titre/TitreStyle.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreStyle.cs @@ -1,4 +1,4 @@ -namespace Webzine.WebApplication.ViewsModels.Titre; +namespace Webzine.WebApplication.ViewModels.Titre; public class TitreStyle { diff --git a/Webzine.WebApplication/ViewsModels/Titre/TitreStyleItem.cs b/Webzine.WebApplication/ViewModels/Titre/TitreStyleItem.cs similarity index 82% rename from Webzine.WebApplication/ViewsModels/Titre/TitreStyleItem.cs rename to Webzine.WebApplication/ViewModels/Titre/TitreStyleItem.cs index 647f61f..4497ca0 100644 --- a/Webzine.WebApplication/ViewsModels/Titre/TitreStyleItem.cs +++ b/Webzine.WebApplication/ViewModels/Titre/TitreStyleItem.cs @@ -1,4 +1,4 @@ -namespace Webzine.WebApplication.ViewsModels.Titre; +namespace Webzine.WebApplication.ViewModels.Titre; public class TitreStyleItem { diff --git a/Webzine.WebApplication/Views/Accueil/Index.cshtml b/Webzine.WebApplication/Views/Accueil/Index.cshtml index ca80480..0312cde 100644 --- a/Webzine.WebApplication/Views/Accueil/Index.cshtml +++ b/Webzine.WebApplication/Views/Accueil/Index.cshtml @@ -1,118 +1,75 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ +@model Webzine.WebApplication.ViewModels.Accueil.AccueilIndexViewModel @{ ViewData["Title"] = "Accueil"; }

Derniers titres chroniqués

-
+@* TEMPLATE *@ +@*
Alternate Text + src="" />
Justice - D.A.N.C.E

- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum - dolore eu fugiat nulla pariatur, Ut enim ad minim veniam quis nostrud - exercitation ullamco laboris nisi ut aliquip ex ea commodo ... + Insérer texte

Lire la suite
+ Date : 17/12/2022 11:08:08
-
-
- Alternate Text -
-
- Justice - D.A.N.C.E -

- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum - dolore eu fugiat nulla pariatur, Ut enim ad minim veniam quis nostrud - exercitation ullamco laboris nisi ut aliquip ex ea commodo ... -

- *@ -
- - 17/12/2022 11:08:08 -
+
+ @foreach (var titre in Model.DerniersTitres) + { +
+
+ +
+
+ @* Artiste - Titre @titre.Artiste - @titre.Libelle*@ + @titre.Artiste.Nom - @titre.Libelle + @* Chronique *@ +

+ @titre.Chronique +

+
+ Lire la suite -
- - Electro disco +
+ + @* Date de création *@ + @titre.DateCreation +
+ +
+ + @* Style *@ + STYLE +
-
-
-
- Alternate Text -
-
- Justice - D.A.N.C.E -

- Duis aute irure dolor in reprehenderit in voluptate velit esse cillum - dolore eu fugiat nulla pariatur, Ut enim ad minim veniam quis nostrud - exercitation ullamco laboris nisi ut aliquip ex ea commodo ... -

-
- Lire la suite - -
- - 17/12/2022 11:08:08 -
- - -
-
-
+ }
@@ -121,53 +78,12 @@

Titres les plus populaires

-
+@* TEMPLATE *@ +@*
Alternate Text - -
- Album
- par Artiste -
-
-
- Alternate Text - -
- Album
- par Artiste -
-
-
- Alternate Text + src="" alt="Alternate Text" />
Album
@@ -175,4 +91,21 @@
+
*@ +
+
+ @foreach (var titre in Model.TopTitres) + { +
+ + + +
+ } +
+
\ No newline at end of file diff --git a/Webzine.WebApplication/Views/Artiste/Index.cshtml b/Webzine.WebApplication/Views/Artiste/Index.cshtml new file mode 100644 index 0000000..2063243 --- /dev/null +++ b/Webzine.WebApplication/Views/Artiste/Index.cshtml @@ -0,0 +1,70 @@ +@model Webzine.WebApplication.ViewModels.ArtisteModel + +@{ + ViewData["Title"] = "Artiste"; +} + + +
+

@Model.Artiste.Nom

+ +
+ +

@Model.Artiste.Biographie

+ +

Albums

+
+ + @* On groupe les titres par nom d'album *@ + @{ + var albumsGroupes = Model.Titres + .OrderBy(t => t.Libelle) // Trie les titres par ordre alphabétique au sein de chaque groupe futur + .GroupBy(t => t.Album) // Groupe par nom d'album + .OrderBy(g => g.Key); // Trie les albums par ordre alphabétique (la clé du groupe) + } + + @foreach (var groupe in albumsGroupes) + { + // On récupère le premier titre du groupe pour afficher l'image de l'album + var premierTitre = groupe.First(); + +
+
+ Pochette de @groupe.Key +
+ +
+

@groupe.Key

+ + + + + + + + + + @foreach (var titre in groupe) + { + // Conversion des secondes en format MM:SS + var minutes = titre.Duree / 60; + var secondes = titre.Duree % 60; + var dureeFormatee = $"{minutes}:{secondes:D2}"; + + + + + + } + +
DuréeTitre
@dureeFormatee + + @titre.Libelle + +
+
+
+ } +
\ No newline at end of file diff --git a/Webzine.WebApplication/Views/Contact/Index.cshtml b/Webzine.WebApplication/Views/Contact/Index.cshtml new file mode 100644 index 0000000..d972463 --- /dev/null +++ b/Webzine.WebApplication/Views/Contact/Index.cshtml @@ -0,0 +1,66 @@ +@{ + ViewData["Title"] = "Contact"; +} + +
+

Contact

+
+ C.U.C.D.B - DIIAGE
+ 69 Avenue Aristide Briand
+ 21000 Dijon +
+
+ Phone : 03 80 40 50 60
+ secretariat@cucdb.fr +
+ +
+ + \ No newline at end of file diff --git a/Webzine.WebApplication/Views/Shared/_Layout.cshtml b/Webzine.WebApplication/Views/Shared/_Layout.cshtml index 9d5545a..80e4341 100644 --- a/Webzine.WebApplication/Views/Shared/_Layout.cshtml +++ b/Webzine.WebApplication/Views/Shared/_Layout.cshtml @@ -6,9 +6,9 @@ @ViewData["Title"] - Webzine @* Ajout de bootstrap *@ - - - + + + @* Ajout de font-awesome *@ diff --git a/Webzine.WebApplication/Views/Titre/Details.cshtml b/Webzine.WebApplication/Views/Titre/Details.cshtml index 287f820..95619a4 100644 --- a/Webzine.WebApplication/Views/Titre/Details.cshtml +++ b/Webzine.WebApplication/Views/Titre/Details.cshtml @@ -1,4 +1,4 @@ -@model Webzine.WebApplication.ViewsModels.Titre.TitreDetail +@model Webzine.WebApplication.ViewModels.Titre.TitreDetail @{ ViewData["Title"] = Model.Details.Libelle; diff --git a/Webzine.WebApplication/Views/Titre/Style.cshtml b/Webzine.WebApplication/Views/Titre/Style.cshtml index cd85fd9..c9ea729 100644 --- a/Webzine.WebApplication/Views/Titre/Style.cshtml +++ b/Webzine.WebApplication/Views/Titre/Style.cshtml @@ -1,4 +1,4 @@ -@model Webzine.WebApplication.ViewsModels.Titre.TitreStyle +@model Webzine.WebApplication.ViewModels.Titre.TitreStyle @{ ViewData["Title"] = $"Titres - {Model.StyleName}"; diff --git a/Webzine.WebApplication/Webzine.WebApplication.csproj b/Webzine.WebApplication/Webzine.WebApplication.csproj index 05ecd07..cce23e9 100644 --- a/Webzine.WebApplication/Webzine.WebApplication.csproj +++ b/Webzine.WebApplication/Webzine.WebApplication.csproj @@ -18,15 +18,14 @@ - - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -35,22 +34,7 @@ - - - - <_ContentIncludedByDefault Remove="Views\Titre2\Create.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Titre2\Delete.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Titre2\Edit.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Titre2\Index.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Titre2\_Form.cshtml" /> - - - - - - - - + diff --git a/Webzine.WebApplication/Webzine.WebApplication.csproj.user b/Webzine.WebApplication/Webzine.WebApplication.csproj.user index ea9a183..2702025 100644 --- a/Webzine.WebApplication/Webzine.WebApplication.csproj.user +++ b/Webzine.WebApplication/Webzine.WebApplication.csproj.user @@ -2,9 +2,12 @@ https - MvcControllerWithActionsScaffolder + MvcControllerEmptyScaffolder root/Common/MVC/Controller RazorViewEmptyScaffolder root/Common/MVC/View + + ProjectDebugger + \ No newline at end of file diff --git a/Webzine.WebApplication/appsettings.json b/Webzine.WebApplication/appsettings.json index 10f68b8..24a6a17 100644 --- a/Webzine.WebApplication/appsettings.json +++ b/Webzine.WebApplication/appsettings.json @@ -5,5 +5,9 @@ "Microsoft.AspNetCore": "Warning" } }, + "Webzine": { + "NombreDerniereChronique": 3, + "NombreDeTopTitres" : 5 + }, "AllowedHosts": "*" }