예제 #1
0
        public override ActionResult NodeView(HasPermissionsCondition condition)
        {
            if (condition.RoleId == null || condition.NodeId == null)
            {
                throw new NopException("参数没有赋值!");
            }
            ViewBag.RoleId = condition.RoleId.ToString();
            ViewBag.MenuId = condition.NodeId.ToString();

            //该菜单所有的自定义权限
            var customPermissionsService = new CustomPermissionsService();
            var customPermissions        = customPermissionsService.GetCustomPermissionsByMenu(condition.NodeId);
            //该角色对应菜单的自定义权限
            var hasPermissionsService = new HasPermissionsService();
            var hasPermissions        = hasPermissionsService.GetRoleHasPermissions(condition.RoleId, condition.NodeId);

            List <RoleHasPermissionsModel> models = new List <RoleHasPermissionsModel>();

            customPermissions.ForEach(p =>
            {
                var model = new RoleHasPermissionsModel()
                {
                    Id = p.Id,
                    CustomPermissionsName = p.Name,
                    HasPermission         = hasPermissions.Any(hp => hp.PermissionId == p.Id)
                };
                models.Add(model);
            });

            return(PartialView(models));
        }
예제 #2
0
        public override ActionResult NodeView(CustomPermissionsCondition condition)
        {
            var customPermissions = customPermissionsService.GetCustomPermissionsByMenu(condition);
            var models            = new PagedList <CustomPermissions>(customPermissions, customPermissions.Paging);

            ViewBag.MenuId = condition.NodeId.ToString();
            return(View(models));
        }