Esempio n. 1
0
        /// <summary>
        /// 更新菜单
        /// </summary>
        /// <param name="id"></param>
        public void UpdateMenu(SysMenu enity, string[] perssions)
        {
            _db.Entry(enity).State = EntityState.Modified;


            var menuPermission = _db.SysMenuPermission.Where(r => r.MenuId == enity.Id).ToList();

            foreach (var m in menuPermission)
            {
                _db.SysMenuPermission.Remove(m);
            }


            if (perssions != null)
            {
                foreach (var m in perssions)
                {
                    _db.SysMenuPermission.Add(new SysMenuPermission {
                        MenuId = enity.Id, PermissionId = m
                    });
                }
            }


            _db.SaveChanges();
        }
Esempio n. 2
0
        /// <summary>
        /// 更新菜单
        /// </summary>
        /// <param name="id"></param>
        public void UpdateMenu(int operater, SysMenu sysMenu, string[] perssions)
        {
            sysMenu.Mender           = operater;
            sysMenu.LastUpdateTime   = DateTime.Now;
            _db.Entry(sysMenu).State = EntityState.Modified;



            var sysMenuPermission = _db.SysMenuPermission.Where(r => r.MenuId == sysMenu.Id).ToList();

            foreach (var m in sysMenuPermission)
            {
                _db.SysMenuPermission.Remove(m);
            }


            if (perssions != null)
            {
                foreach (var m in perssions)
                {
                    _db.SysMenuPermission.Add(new SysMenuPermission {
                        MenuId = sysMenu.Id, PermissionId = m
                    });
                }
            }

            AddOperateHistory(operater, Enumeration.OperateType.Update, sysMenu.Id, string.Format("修改菜单(ID:{0})", sysMenu.Id));

            _db.SaveChanges();
        }