You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
//using App.Models;
|
|
using Microsoft.AspNetCore.Http;
|
|
using BWPMModels;
|
|
using App.Models;
|
|
|
|
namespace APP.ViewComponents
|
|
{
|
|
public class MenuItemsViewComponent : ViewComponent
|
|
{
|
|
List<Object> menuItems = new List<Object>();
|
|
//List<AppMenuItem> menuItems = new List<AppMenuItem>();
|
|
public MenuItemsViewComponent()
|
|
{
|
|
//HttpContext.Session.SetString("usertype","1");
|
|
//string usertype = HttpContext.Session.GetString("usertype");
|
|
menuItems = AppMenuItem.MenuItems("1");
|
|
string state = "";
|
|
try
|
|
{
|
|
state = HttpContext.Session.GetString("LoggedIn");
|
|
|
|
}
|
|
catch
|
|
{
|
|
state = "";
|
|
}
|
|
|
|
if (state == "" || state == "False")
|
|
{ menuItems.Add(new AppMenuItem { id = "999", text = "Login", parentId = "", url = "/Home/Login" }); }
|
|
;
|
|
ViewBag.menuitems = menuItems;
|
|
var model = menuItems;
|
|
}
|
|
|
|
public async Task<IViewComponentResult> InvokeAsync()
|
|
{
|
|
var model = menuItems;
|
|
ViewBag.menuitems = menuItems;
|
|
return await Task.FromResult((IViewComponentResult)View("MenuItems", model));
|
|
}
|
|
|
|
}
|
|
}
|