Calendar/app/Features/Menu/SideMenuViewComponent.cs
Janus C. H. Knudsen d7f3c55a2a Restructures project with feature-based organization
Refactors project structure to support modular, feature-driven development

Introduces comprehensive language localization support
Adds menu management with role-based access control
Implements dynamic sidebar and theme switching capabilities

Enhances project scalability and maintainability
2026-01-08 15:44:11 +01:00

35 lines
955 B
C#

using Microsoft.AspNetCore.Mvc;
using CalendarServer.Features.Menu.Models;
using CalendarServer.Features.Menu.Services;
namespace CalendarServer.Features.Menu;
/// <summary>
/// ViewComponent for rendering the side menu based on user role.
/// </summary>
public class SideMenuViewComponent : ViewComponent
{
private readonly IMenuService _menuService;
public SideMenuViewComponent(IMenuService menuService)
{
_menuService = menuService;
}
public IViewComponentResult Invoke(UserRole? role = null)
{
// Default to Admin for demo (in real app, get from auth)
var userRole = role ?? UserRole.Admin;
var currentUrl = HttpContext.Request.Path.Value;
var groups = _menuService.GetMenuForRole(userRole, currentUrl);
var viewModel = new SideMenuViewModel
{
Groups = groups,
CurrentUserRole = userRole
};
return View(viewModel);
}
}