예제 #1
0
        public ActionResult GetAllRoleValues()
        {
            var result = ResModelFactory.ResDefaultData <TreeDataViewModel>();
            //获取所有菜单
            SystemMenuService services = new SystemMenuService();
            var menus = services.GetEntitys(p => true).ToList();
            //权限树形结构
            var treedata = new List <TreeDataViewModel>();
            //
            //找出父菜单
            var parents = menus.Where(p => string.IsNullOrEmpty(p.ParentID));

            foreach (var par in parents)
            {
                var tree = new TreeDataViewModel();
                tree.title    = par.MenuName;
                tree.id       = par.ID;
                tree.spread   = true;
                tree.@checked = true;
                if (par.IsShow.Value)
                {
                    tree.disabled = false;
                }
                else
                {
                    tree.disabled = true;
                }
                var childs = menus.Where(p => p.ParentID == p.ID);
                tree.children = GettreeData(menus, par.ID).ToArray();
                treedata.Add(tree);
            }
            result.data = treedata.ToArray();
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult GetMenuById(string id)
        {
            SystemMenuService service = new SystemMenuService();
            var menu = service.GetEntitys(p => p.ID == id).FirstOrDefault();

            return(View("AddMenu", menu));
        }
예제 #3
0
        public ActionResult GetAllMenu()
        {
            var result = ResModelFactory.ResDefaultData <SystemMenu>();
            SystemMenuService service = new SystemMenuService();
            var list = service.GetEntitys(p => true);

            result.data = list.ToArray();
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
예제 #4
0
        public ActionResult EditMenu(SystemMenu entity)
        {
            var result = ResModelFactory.ResDefault();

            try
            {
                SystemMenuService service = new SystemMenuService();
                SystemMenu        model   = service.GetEntitys(p => p.ID == entity.ID).FirstOrDefault();
                model.MenuName = entity.MenuName;
                model.LinkUrl  = entity.LinkUrl;
                model.ParentID = entity.ParentID;
                model.Icon     = entity.Icon;
                model.IsShow   = entity.IsShow;

                model.ModifyUserId = CurrentUser.Id;
                model.NodifyDate   = DateTime.Now;
                var user = service.Update(model);
            }
            catch (Exception ex)
            {
                result = ResModelFactory.ResError(ex.Message);
            }
            return(Json(result));
        }