Exemplo n.º 1
0
        public ActionResult BindMenu(int Id, string MenuIds)
        {
            var result = new BackRoleMenuBindBLL().BindMenu(Id, MenuIds);

            var response = new ResponseEntity <int>(result.Success, result.Message, result.Data);

            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult GetMenuIdsByRoleId(int Id)
        {
            List <BackRoleMenuBind> BindListMenu = new List <BackRoleMenuBind>();

            BindListMenu = new BackRoleMenuBindBLL().GetMenuIdsByRoleId(Id).ToList();

            List <BackMenu> ListMenu = new List <BackMenu>();

            ListMenu = new BackMenuBLL().GetDataAll();

            List <BindMenu> MyMenu = new List <BindMenu>();

            foreach (var v in ListMenu.Where(T => T.ParentId == 0))
            {
                int IsBind         = 0;
                int operationRight = 0;

                if (BindListMenu.Exists(T => T.MenuId == v.Id))
                {
                    IsBind = 1;

                    operationRight = BindListMenu.Where(x => x.MenuId == v.Id).Max(x => x.OperationRight);
                }

                MyMenu.Add(new BindMenu
                {
                    Id             = v.Id,
                    MenuIcon       = v.MenuIcon,
                    ParentId       = 0,
                    AccessUrl      = v.AccessUrl,
                    Sequence       = v.Sequence,
                    Name           = v.Name,
                    MenuNo         = v.MenuNo,
                    IsBind         = IsBind,
                    OperationRight = operationRight
                });
            }
            MyMenu = MyMenu.OrderBy(T => T.Sequence).ToList();

            foreach (var v in MyMenu)
            {
                List <BindMenu> subMenuLi = new List <BindMenu>();

                foreach (var va in ListMenu.Where(T => T.ParentId == v.Id))
                {
                    int IsBind         = 0;
                    int operationRight = 0;

                    if (BindListMenu.Exists(T => T.MenuId == va.Id))
                    {
                        IsBind = 1;

                        operationRight = BindListMenu.Where(x => x.MenuId == va.Id).Max(x => x.OperationRight);
                    }
                    subMenuLi.Add(new BindMenu
                    {
                        Id             = va.Id,
                        MenuIcon       = va.MenuIcon,
                        ParentId       = va.ParentId,
                        AccessUrl      = va.AccessUrl,
                        Sequence       = va.Sequence,
                        Name           = va.Name,
                        MenuNo         = va.MenuNo,
                        IsBind         = IsBind,
                        OperationRight = operationRight
                    });
                }
                v.SubMenuList = subMenuLi;
            }


            return(Json(new ResponseEntity <dynamic>(0, "获取菜单成功", MyMenu), JsonRequestBehavior.AllowGet));
        }