private List <CusMenuAttribute> GetMenuFromList()
        {
            List <CusMenuAttribute> cusMenus = new List <CusMenuAttribute>();
            var user = AuthenticationExtends.CurrentUser;

            if (user != null && user.Role != null)
            {
                var data = MenuExtends.GetMenu().Where(o => o.Type == "Sys" && o.IsShow == true).ToList();
                if (HttpContext.User.IsInRole("administrator"))
                {
                    return(data);
                }
                if (data != null)
                {
                    int _count = data.Count;
                    for (int i = 0; i < _count; i++)
                    {
                        var item = data[i];
                        var role = _sysAccess.GetPermisstion(item.CModule, user.RoleID);
                        if (role != null)
                        {
                            if (role.Where(o => o.Activity == true) != null)
                            {
                                cusMenus.Add(item);
                            }
                        }
                    }
                }
            }
            return(cusMenus);
        }
Example #2
0
 public IActionResult Permission(RolesModel model)
 {
     if (model.ID > 0)
     {
         ViewBag.Control = MenuExtends.GetMenu();
         ViewBag.Access  = _sysAccess.DbQuery.Where(o => o.RoleID == model.ID).ToList();
     }
     else
     {
         ViewBag.Message = "Chưa chọn đối tượng phân quyền";
     }
     ViewBag.Model = model;
     return(View());
 }
Example #3
0
 public IActionResult Index()
 {
     ViewBag.Data = MenuExtends.GetMenu();
     return(View());
 }