public int UpdateRight(SysRightOperateModel model) { //转换 SysRightOperate rightOperate = new SysRightOperate(); rightOperate.Id = model.Id; rightOperate.RightId = model.RightId; rightOperate.KeyCode = model.KeyCode; rightOperate.IsValid = model.IsValid; using (var db = new SysMgr_DBEntities()) { SysRightOperate right = db.SysRightOperate.Where(a => a.Id == rightOperate.Id).FirstOrDefault(); if (right != null) { right.IsValid = rightOperate.IsValid; } else { db.SysRightOperate.Add(rightOperate); } if (db.SaveChanges() > 0) { //更新角色--模块的有效标志RightFlag var sysRight = (from r in db.SysRight where r.Id == rightOperate.RightId select r).FirstOrDefault(); db.P_Sys_UpdateSysRightRightFlag(sysRight.ModuleId, sysRight.RoleId); return(1); } } return(0); }
public SysModule GetById(string id) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { return(db.SysModule.SingleOrDefault(a => a.Id == id)); } }
public List <P_Sys_GetRightByRoleAndModule_Result> GetRightByRoleAndModule(string roleId, string moduleId) { using (var db = new SysMgr_DBEntities()) { var result = db.P_Sys_GetRightByRoleAndModule(roleId, moduleId).ToList(); return(result); } }
public SysUser Login(string username, string pwd) { using (var db = new SysMgr_DBEntities()) { SysUser user = db.SysUser.SingleOrDefault(a => a.UserName == username && a.Password == pwd); return(user); } }
public int Create(SysLog entity) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { db.SysLog.Add(entity); return(db.SaveChanges()); } }
public int Create(SysException entity) { using (var db = new SysMgr_DBEntities()) { db.Set <SysException>().Add(entity); return(db.SaveChanges()); } }
public int Edit(SysModule entity) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { db.SysModule.Attach(entity); db.Entry <SysModule>(entity).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
public int Create(SysRole entity) { //db.Set<SysRole>().Add(entity); using (var db = new SysMgr_DBEntities()) { db.SysRole.Add(entity); return(db.SaveChanges()); } }
public int Edit(SysSample entity) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { db.SysSample.Attach(entity); //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); db.Entry <SysSample>(entity).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges()); } }
public bool IsExist(string id) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { SysModule entity = GetById(id); if (entity != null) { return(true); } return(false); } }
public int Delete(string id) { using (var db = new SysMgr_DBEntities()) { var entity = db.SysRole.Find(id); if (entity != null) { db.Set <SysRole>().Remove(entity); } return(db.SaveChanges()); } }
public int Create(SysModuleOperate entity) { #region MyRegion using (var db = new SysMgr_DBEntities()) { db.SysModuleOperate.Add(entity); return(db.SaveChanges()); } #endregion //db.Set<SysModuleOperate>().Add(entity); //return db.SaveChanges(); }
public int Delete(int id) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { SysSample entity = db.SysSample.SingleOrDefault(a => a.Id == id); if (entity != null) { db.SysSample.Remove(entity); } return(db.SaveChanges()); } }
public List <permModel> GetPermission(string accountid, string controller) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { List <permModel> rights = (from r in db.P_Sys_GetRightOperate(accountid, controller) select new permModel { KeyCode = r.KeyCode, IsValid = r.IsValid }).ToList(); return(rights); } }
public void UpdateSysRoleSysUser(string userId, string[] roleIds) { using (var db = new SysMgr_DBEntities()) { db.P_Sys_DeleteSysRoleSysUserByUserId(userId); foreach (string roleId in roleIds) { if (!string.IsNullOrWhiteSpace(roleId)) { db.P_Sys_UpdateSysRoleSysUser(roleId, userId); } } db.SaveChanges(); } }
public void Delete(string[] deleteCollection) { using (SysMgr_DBEntities db = new SysMgr_DBEntities()) { IQueryable <SysLog> collection = from f in db.SysLog where deleteCollection.Contains(f.Id) select f; foreach (var model in collection) { db.SysLog.Remove(model); } db.SaveChanges(); } }
public List <SysModule> GetMenuByPersonId(string personId, string moduleId) { using (var db = new SysMgr_DBEntities()) { var menus = (from m in db.SysModule join rl in db.SysRight on m.Id equals rl.ModuleId join role in (from r in db.SysRole from u in r.SysUser where u.Id == personId select r) on rl.RoleId equals role.Id where rl.Rightflag == true where m.ParentId == moduleId where m.Id != "0" select m).Distinct().OrderBy(a => a.Sort).ToList(); return(menus); } }