Esempio n. 1
0
        /// <summary>
        /// 添加菜单节点
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="menuName"></param>
        /// <returns></returns>
        public int AddMenu(int parentId, string menuName)
        {
            using (var db = DbAccess.DbFrameworkContext.Create())
            {
                var helper = new BLL.MenuHelper(db, svrUser);
                var menu   = helper.CreateMenuNode(parentId, menuName, null);

                db.SaveChanges();
                return(menu.MenuId);
            }
        }
Esempio n. 2
0
        public bool DeleteMenu(int menuId)
        {
            using (var db = DbAccess.DbFrameworkContext.Create())
            {
                var helper = new BLL.MenuHelper(db, this.svrUser);
                var menu   = helper.GetMenuNode(menuId);

                if (menu == null)
                {
                    throw new UIValidateException("菜单不存在,ID=" + menuId);
                }

                menu.Delete();
                db.SaveChanges();
                return(true);
            }
        }
Esempio n. 3
0
        public bool EditMenu(int oldParentId, SvrModels.SvrMenuInfo svrModel)
        {
            using (var db = DbAccess.DbFrameworkContext.Create())
            {
                var helper = new BLL.MenuHelper(db, this.svrUser);
                var menu   = helper.GetMenuNode(svrModel.MenuId);

                if (menu == null)
                {
                    throw new UIValidateException("菜单不存在,ID=" + svrModel.MenuId);
                }

                menu.UpdateMenuNode(oldParentId, svrModel);
                db.SaveChanges();
                return(true);
            }
        }