NonInventPurchasingSystem/CPRNIMS.WebApps/Views/Shared/PartialView/_Sidebar.cshtml
2026-01-26 14:21:31 +08:00

75 lines
2.8 KiB
Plaintext

@using CPRNIMS.Infrastructure.ViewModel;
@using CPRNIMS.Infrastructure.ViewModel.Account;
@using CPRNIMS.Infrastructure.ViewModel.Common;
@inject CPRNIMS.Domain.UIContracts.Account.IAccount _account;
@model CPRNIMS.Infrastructure.Dto.Attachement.AttachResponseDto
@{
if (!String.IsNullOrEmpty(ViewBag.UserRoles))
{
try
{
string allowedRoles = ViewBag.UserRoles;
var userCred = new CPRNIMS.Infrastructure.Models.Account.User();
userCred.UserName = ViewBag.UserName;
userCred.UserId = ViewBag.UserId;
var myControllerAccess = await _account.GetLandingPageByUserId(userCred);
var groupedElements = myControllerAccess.GroupBy(e => e.ElementMenuName).ToList();
// Pass the data to the view
ViewBag.TempDataElements = groupedElements;
}
catch (Exception)
{
// Console.WriteLine(ex.Message.ToString() ?? ex.InnerException?.ToString());
throw;
}
}
}
<div class="sidebar">
<div class="logo-details">
<i class="bx bxl-c-plus-plus icon"></i>
<div class="logo_name">@ViewBag.UserCompany</div>
<i class="bx bx-menu" id="btn"></i>
</div>
<ul class="nav-list">
<!-- Load partial Admin Nav -->
@await Html.PartialAsync("PartialView/MenuNav/AllUsers/_AllUsersNav")
@foreach (var groupedElement in ViewBag.TempDataElements)
{
//var firstElement = groupedElement.First(); // Assuming it's a list of elements
<li>
<div class="menu-wrapper">
@foreach (var accessElementFirst in groupedElement)
{
ViewBag.IconClassName = @accessElementFirst.IconClassName;
ViewBag.IconSpanName = @accessElementFirst.IconSpanName;
ViewBag.ToolTipName = @accessElementFirst.ToolTipName;
}
<a href="#">
<i class='@ViewBag.IconClassName'></i>
<span class="@ViewBag.IconSpanName">@groupedElement.Key </span>
</a>
<span class="tooltip">@ViewBag.ToolTipName</span>
</div>
<ul class="sub-menu">
@foreach (var accessElement in groupedElement)
{
<li>
<a asp-controller="@accessElement.Controller" asp-action="@accessElement.Action">@accessElement.ToolTipName</a>
</li>
}
</ul>
</li>
}
@* Load User profile *@
@await Html.PartialAsync("PartialView/MenuNav/UserProfile/_UpdateUserProfile")
</ul>
</div>