예제 #1
0
        public void SetMenuPermission(string menuid, params string[] permissionid)
        {
            Menu2PermissionDAL m2p = new Menu2PermissionDAL();
            //先删除所有相关权限
            var mlist = m2p.GetAll().Where(o => o.MenuID == menuid);

            if (mlist != null)
            {
                foreach (var p in mlist)
                {
                    m2p.Delete(p);
                }
            }
            //再增加所有权限
            if (permissionid != null && permissionid.Length > 0)
            {
                foreach (var p in permissionid)
                {
                    Menu2Permission mp = new Menu2Permission();
                    mp.ID           = Guid.NewGuid().ToString();
                    mp.MenuID       = menuid;
                    mp.PermissionID = p;
                    m2p.Add(mp);
                }
            }

            m2p.AcceptAllChange();
        }
예제 #2
0
        public bool DeleteMenu(string menuid)
        {
            var chidlist = base.GetAll().Where(o => o.ParentID == menuid);

            if (chidlist.Any())
            {
                return(false);
            }
            Menu2PermissionDAL m2p = new Menu2PermissionDAL();
            var m2plist            = m2p.GetAll().Where(o => o.MenuID == menuid);

            foreach (var m in m2plist)
            {
                m2p.Delete(m);
            }
            var model = base.Get(menuid);

            base.Delete(model);
            AcceptAllChange();
            return(true);
        }