diff --git a/Webzine.WebApplication/Controllers/ArtisteController.cs b/Webzine.WebApplication/Controllers/ArtisteController.cs index 68b2443..b63f140 100644 --- a/Webzine.WebApplication/Controllers/ArtisteController.cs +++ b/Webzine.WebApplication/Controllers/ArtisteController.cs @@ -31,7 +31,7 @@ [HttpGet("/artiste/{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); if (string.IsNullOrEmpty(nom)) { diff --git a/Webzine.WebApplication/ViewComponents/SidebarViewComponent.cs b/Webzine.WebApplication/ViewComponents/SidebarViewComponent.cs new file mode 100644 index 0000000..27f2c7a --- /dev/null +++ b/Webzine.WebApplication/ViewComponents/SidebarViewComponent.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Mvc; +using Webzine.Repository.Contracts; + +namespace Webzine.WebApplication.ViewComponents +{ + /// + /// View component pour la sidebar, récupère les styles depuis le repository. + /// + public class SidebarViewComponent : ViewComponent + { + private readonly IStyleRepository styleRepository; + + /// + /// Initializes a new instance of the class. + /// + /// Repository des styles injecté. + public SidebarViewComponent(IStyleRepository styleRepository) + { + this.styleRepository = styleRepository; + } + + /// + /// Récupère tous les styles triés par libellé et les passe à la vue. + /// + /// Une vue contenant la liste des styles. + public IViewComponentResult Invoke() + { + var styles = this.styleRepository.FindAll() + .OrderBy(s => s.Libelle) + .ToList(); + + return this.View(styles); + } + } +} \ No newline at end of file diff --git a/Webzine.WebApplication/Views/Shared/Components/Sidebar/Default.cshtml b/Webzine.WebApplication/Views/Shared/Components/Sidebar/Default.cshtml new file mode 100644 index 0000000..d7ce8b9 --- /dev/null +++ b/Webzine.WebApplication/Views/Shared/Components/Sidebar/Default.cshtml @@ -0,0 +1,23 @@ +@model IEnumerable + + \ No newline at end of file diff --git a/Webzine.WebApplication/Views/Shared/_Layout.cshtml b/Webzine.WebApplication/Views/Shared/_Layout.cshtml index 234b357..5d11de0 100644 --- a/Webzine.WebApplication/Views/Shared/_Layout.cshtml +++ b/Webzine.WebApplication/Views/Shared/_Layout.cshtml @@ -11,19 +11,19 @@ - -
-
-
- @RenderBody() -
- @if(ViewContext.RouteData.Values["area"]?.ToString() != "Administration") - { - - } -
+ +
+
+
+ @RenderBody() +
+ @if(ViewContext.RouteData.Values["area"]?.ToString() != "Administration") + { + @await Component.InvokeAsync("Sidebar") + }
- +
+ diff --git a/Webzine.WebApplication/Views/Shared/_Sidebar.cshtml b/Webzine.WebApplication/Views/Shared/_Sidebar.cshtml deleted file mode 100644 index 49dedf2..0000000 --- a/Webzine.WebApplication/Views/Shared/_Sidebar.cshtml +++ /dev/null @@ -1,51 +0,0 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ -@{ -} - \ No newline at end of file