36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
namespace Webzine.WebApplication.ViewComponents
|
|
{
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Webzine.Repository.Contracts;
|
|
|
|
/// <summary>
|
|
/// View component pour la sidebar, récupère les styles depuis le repository.
|
|
/// </summary>
|
|
public class SidebarViewComponent : ViewComponent
|
|
{
|
|
private readonly IStyleRepository styleRepository;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="SidebarViewComponent"/> class.
|
|
/// </summary>
|
|
/// <param name="styleRepository">Repository des styles injecté.</param>
|
|
public SidebarViewComponent(IStyleRepository styleRepository)
|
|
{
|
|
this.styleRepository = styleRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Récupère tous les styles triés par libellé et les passe à la vue.
|
|
/// </summary>
|
|
/// <returns>Une vue contenant la liste des styles.</returns>
|
|
public IViewComponentResult Invoke()
|
|
{
|
|
var styles = this.styleRepository.FindAll()
|
|
.OrderBy(s => s.Libelle)
|
|
.ToList();
|
|
|
|
return this.View(styles);
|
|
}
|
|
}
|
|
} |