public virtual ActionResult AddModule(string roleName) { if (string.IsNullOrEmpty(roleName)) { return(RedirectToAction("Index")); } GrantModulesToRoleViewModel model = new GrantModulesToRoleViewModel(); model.RoleName = roleName; model.GUID = roleRepo.FindByName(roleName).RoleId.ToString(); string actionId = actionRepo.Find().Select(m => m.Id).FirstOrDefault().ToString(); List <Business.Entities.Module> availableMOdules = moduleRepo.Find(); List <Business.Entities.Module> usedModules = roleRepo.FindByName(roleName).ModulesInRoles.Select(m => m.Module).ToList(); //used action foreach (Business.Entities.Module a in usedModules) { availableMOdules.RemoveAll(x => x.ModuleName == a.ModuleName); } List <ModuleStub> availableMOduleStub = new ModuleStub().MapList(availableMOdules, actionId); List <ModuleStub> usedModuleStub = new ModuleStub().MapList(usedModules, actionId); model.AvailableModules = new SelectList(availableMOduleStub, "Id", "ModuleName"); model.GrantedModules = new SelectList(usedModuleStub, "Id", "ModuleName"); return(View(model)); }
public LoginUserVM Login(string userName, string password) { var user = _repository.FindSingle(u => u.Account == userName); if (user == null) { throw new Exception("用户帐号不存在"); } user.CheckPassword(password); var loginVM = new LoginUserVM { User = user }; //用户角色 var userRoleIds = _relevanceRepository.Find(u => u.FirstId == user.Id && u.Key == "UserRole").Select(u => u.SecondId).ToList(); //用户角色与自己分配到的模块ID var moduleIds = _relevanceRepository.Find( u => (u.FirstId == user.Id && u.Key == "UserModule") || (u.Key == "RoleModule" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); //用户角色与自己分配到的菜单ID var elementIds = _relevanceRepository.Find( u => (u.FirstId == user.Id && u.Key == "UserElement") || (u.Key == "RoleElement" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); //得出最终用户拥有的模块 loginVM.Modules = _moduleRepository.Find(u => moduleIds.Contains(u.Id)).OrderBy(u => u.SortNo).MapToList <ModuleView>(); //模块菜单权限 foreach (var module in loginVM.Modules) { module.Elements = _moduleElementRepository.Find(u => u.ModuleId == module.Id && elementIds.Contains(u.Id)).OrderBy(u => u.Sort).ToList(); } //用户角色与自己分配到的资源ID var resourceIds = _relevanceRepository.Find( u => (u.FirstId == user.Id && u.Key == "UserResource") || (u.Key == "RoleResource" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); loginVM.Resources = _resourceRepository.Find(u => resourceIds.Contains(u.Id)).ToList(); //用户角色与自己分配到的机构ID var orgids = _relevanceRepository.Find( u => (u.FirstId == user.Id && u.Key == "UserAccessedOrg") || (u.Key == "RoleAccessedOrg" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); loginVM.AccessedOrgs = _orgRepository.Find(u => orgids.Contains(u.Id)).ToList(); return(loginVM); }
public IHttpActionResult GetModule(int id) { Module module = (Module)moduleRepo.Find(id); if (module == null) { return(NotFound()); } Mapper.Initialize(c => c.CreateMap <Module, ModuleDTO>()); ModuleDTO moduleDTO = Mapper.Map <ModuleDTO>(module); return(Ok(moduleDTO)); }
public void GetUserAccessed(string name) { if (name == "System") { _modules = _moduleRepository.Find(null).ToList(); _moduleElements = _moduleElementRepository.Find(null).ToList(); _resources = _resourceRepository.Find(null).OrderBy(u => u.SortNo).ToList(); _orgs = _orgRepository.Find(null).OrderBy(u => u.SortNo).ToList(); } else { _user = _repository.FindSingle(u => u.Account == name); //用户角色 var userRoleIds = _relevanceRepository.Find(u => u.FirstId == _user.Id && u.Key == "UserRole").Select(u => u.SecondId).ToList(); //用户角色与自己分配到的模块ID var moduleIds = _relevanceRepository.Find( u => (u.FirstId == _user.Id && u.Key == "UserModule") || (u.Key == "RoleModule" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); //用户角色与自己分配到的菜单ID var elementIds = _relevanceRepository.Find( u => (u.FirstId == _user.Id && u.Key == "UserElement") || (u.Key == "RoleElement" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); //得出最终用户拥有的模块 _modules = _moduleRepository.Find(u => moduleIds.Contains(u.Id)).OrderBy(u => u.SortNo).ToList(); //模块菜单权限 _moduleElements = _moduleElementRepository.Find(u => elementIds.Contains(u.Id)).ToList(); //用户角色与自己分配到的资源ID var resourceIds = _relevanceRepository.Find( u => (u.FirstId == _user.Id && u.Key == "UserResource") || (u.Key == "RoleResource" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); _resources = _resourceRepository.Find(u => resourceIds.Contains(u.Id)).ToList(); //用户角色与自己分配到的机构ID var orgids = _relevanceRepository.Find( u => (u.FirstId == _user.Id && u.Key == "UserAccessedOrg") || (u.Key == "RoleAccessedOrg" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); _orgs = _orgRepository.Find(u => orgids.Contains(u.Id)).ToList(); } }
public virtual ActionResult Index() { //kamus ManageModulesViewModel model = new ManageModulesViewModel(); var modules = moduleRepo.Find(); string[] actionsArr = new string[100]; //algo actionsArr = new string[modules.Count]; for (int i = 0; i < modules.Count; ++i) { actionsArr[i] = modules[i].ModuleName; } model.Modules = new SelectList(actionsArr); model.ModuleList = actionsArr; return(View(model)); }
public IActionResult DeleteModule(long id) { Module module = _module_repo.Find(id); if (module == null) { return(NotFound()); } _module_repo.Delete(module); return(Ok()); }
/// <summary> /// 加载特定用户的模块 /// </summary> /// <param name="userId">The user unique identifier.</param> public List <Module> LoadForUser(Guid userId) { //用户角色 var userRoleIds = _relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserRole").Select(u => u.SecondId).ToList(); //用户角色与自己分配到的模块ID var moduleIds = _relevanceRepository.Find( u => (u.FirstId == userId && u.Key == "UserModule") || (u.Key == "RoleModule" && userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId).ToList(); //var moduleIds = // _relevanceRepository.Find(u => u.FirstId == userId && u.Key == "UserModule") // .Select(u => u.SecondId) // .ToList(); if (!moduleIds.Any()) { return(new List <Module>()); } return(_repository.Find(u => moduleIds.Contains(u.Id)).ToList()); }
public OperationResult FindByModuleCode(string moduleCode) { OperationResult result = new OperationResult(); if (string.IsNullOrEmpty(moduleCode)) { result.ResultType = OperationResultType.ParamError; result.Message = "参数错误,模块编号不能为空"; return(result); } try { var data = _moduleRepository.Find(m => m.Code == moduleCode); result.ResultType = OperationResultType.Success; result.Message = "模块编号查询成功"; result.AppendData = data.ToList().FirstOrDefault(); } catch (Exception ex) { base.ProcessException(ref result, string.Format("根据模块编号获取{0}数据实体出错", base.EntityType), ex); } return(result); }
public virtual ActionResult Index() { DashboardViewModel viewModel = new DashboardViewModel(); int totalRecords; membershipService.GetAllUsers(0, 20, out totalRecords); viewModel.TotalUserCount = totalRecords.ToString(); viewModel.TotalUsersOnlineCount = membershipService.GetNumberOfUsersOnline().ToString(); viewModel.TotalRolesCount = roleService.GetAllRoles().Length.ToString(); viewModel.TotalActionsCount = actionRepo.Find().Count.ToString(); viewModel.TotalModulesCount = moduleRepo.Find().Count.ToString(); //viewModel.TotalJabatanCount = jabatanRepo.Find().Count.ToString(); return(View(viewModel)); }
public virtual ActionResult AddModule(string role) { if (role == null) { return(RedirectToAction("Index")); } AddModulesToRoleViewModel model = new AddModulesToRoleViewModel(); List <Module> temp = new List <Module>(); string render = ""; model.RoleName = role; model.Actions = actionRepo.Find(); //var rootModule = moduleRepo.Find().FindAll(x => x.ParentModule == null); Role r = roleRepo.FindByName(role); //foreach (Module m in rootModule) { // moduleRepo.GetAllChildrenInModule(m.ModuleName,ref temp, 0); //} //foreach (Module m in temp) { // render += DrawRowModule(m.lvl, m, model.Actions, r); //} List <Module> modules = moduleRepo.Find(); List <ModuleViewModel> mvms = new ModuleViewModel().MapRecursive(modules); foreach (ModuleViewModel m in mvms) { render += DrawRowModule(m.Level, m, model.Actions, r); } model.Render = render; return(View(model)); }
public void AddOrUpdate(Module model) { ChangeModuleCascade(model); if (model.Id == Guid.Empty) { _repository.Add(model); } else { //获取旧的的CascadeId var CascadeId = _repository.FindSingle(o => o.Id == model.Id).CascadeId; //根据CascadeId查询子部门 var models = _repository.Find(u => u.CascadeId.Contains(CascadeId) && u.Id != model.Id).OrderBy(u => u.CascadeId).ToList(); _repository.Update(model); //更新子部门的CascadeId foreach (var a in models) { ChangeModuleCascade(a); _repository.Update(a); } } }
public ModuleDTO GetModuleByID(Guid id) { var module = moduleRepository.Find(Specification <Module> .Eval(m => m.ID.Equals(id))); return(Mapper.Map <Module, ModuleDTO>(module).ToViewModel()); }
/// <summary> /// 为树型结构提供数据 /// </summary> public List <Module> LoadForTree() { return(_repository.Find(null).ToList()); }
public IEnumerable <Feature> GetAllModuleFeatures([FromBody] IList <long> moduleids) { var AllFeatures = ReadJson(); List <string> features = new List <string>(); IList <Feature> featureList = new List <Feature>(); foreach (long moduleid in moduleids) { Module module = module_repo.Find(moduleid); if (module.Name == "Human Resource Management") { features.AddRange(AllFeatures.HRMS); } if (module.Name == "Hospital Management System") { features.AddRange(AllFeatures.HIMS); } if (module.Name == "Payroll Management System") { features.AddRange(AllFeatures.Payroll); } if (module.Name == "Lab Information System") { features.AddRange(AllFeatures.Lab); } if (module.Name == "Inventory") { features.AddRange(AllFeatures.Inventory); } if (module.Name == "eTracker") { features.AddRange(AllFeatures.ETracker); } if (module.Name == "eTrackerMobile") { features.AddRange(AllFeatures.ETrackerMobile); } if (module.Name == "Security Admin") { features.AddRange(AllFeatures.Security); } if (features != null) { foreach (var feature in features) { var feat = new Feature { CompanyId = module.CompanyId, ModuleId = module.ModuleId, Name = feature }; featureList.Add(feat); } } } return(featureList); }
private bool CheckIfModuleExists(string name) { return(_moduleRepository.Find(x => x.Name == name) != null); }
public Domain.Module Find(Expression <Func <Domain.Module, bool> > predicate) { return(_repository.Find(predicate)); }