public async Task <IActionResult> Get() { IEnumerable <SysUserDto> entityDto = null; var users = _sysUserRpt.FindBy(f => f.IsDelete == false).ToList(); entityDto = _mapper.Map <IEnumerable <sys_user>, IEnumerable <SysUserDto> >(users).ToList(); var sysRoleList = _sysRoleRpt.GetAll().ToList(); var orgList = _orgRepository.GetAll().ToList(); foreach (var item in entityDto) { //角色名称转换 List <string> roleName = new List <string>(); if (!string.IsNullOrEmpty(item.RoleIds)) { string[] roleid = item.RoleIds.Split(",".ToCharArray()); for (int i = 0; i < roleid.Length; i++) { if (!string.IsNullOrEmpty(roleid[i])) { var role = sysRoleList.Find(f => f.Id == int.Parse(roleid[i])); if (role != null) { roleName.Add(role.RoleName); } } } } item.OrgIdTxt = orgList.FirstOrDefault(f => f.Id == item.OrgId)?.DeptName; item.RoleNames = string.Join(",", roleName); } return(new OkObjectResult(entityDto.ToList().OrderBy(f => f.UserName))); }
public IActionResult GetUserList(int id) { return(new OkObjectResult(_sysUserRpt.FindBy(f => f.IsValid && f.OrgId == id).ToList())); }