/// <summary> /// 获取特定租户的用户分页列表 /// </summary> public async Task <PagedResultDto <UserOutput> > GetUsers(GetUsersInput input, int tenantId) { using (CurrentUnitOfWork.SetTenantId(tenantId)) { return(await _userAppService.GetUsers(input)); } }
/// <summary> /// 获取分页的用户数据 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <PagedResultDto <UserListDto> > GetUsers(GetUsersInput input) { var query = UserManager.Users .WhereIf(input.Role.HasValue, u => u.Roles.Any(r => r.RoleId == input.Role.Value)) .WhereIf(input.OnlyLockedUsers, u => u.LockoutEndDateUtc.HasValue && u.LockoutEndDateUtc.Value > DateTime.UtcNow) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) ); var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var userListDtos = ObjectMapper.Map <List <UserListDto> >(users); return(new PagedResultDto <UserListDto>( userCount, userListDtos )); }
public async Task <PagedResultDto <UserListDto> > GetUsers(GetUsersInput input) { var query = GetUsersFilteredQuery(input); var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var userListDtos = ObjectMapper.Map <List <UserListDto> >(users); foreach (var user in userListDtos) { var org = _organizationUnitRepository.FirstOrDefault(x => x.Id == user.OrganizationUnitId); if (org != null) { user.UnitName = org.DisplayName; } var jobTitle = _jobTitleRepository.FirstOrDefault(x => x.Id == user.JobTitleId); if (jobTitle != null) { user.JobTitleName = jobTitle.NameAr; } } await FillRoleNames(userListDtos); return(new PagedResultDto <UserListDto>( userCount, userListDtos )); }
private IQueryable <User> QueryUser(GetUsersInput input) { var query = UserManager.Users .Include(u => u.Roles) .WhereIf(input.Role.HasValue, u => u.Roles.Any(r => r.RoleId == input.Role.Value)) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || //u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) || u.PhoneNumber.Contains(input.Filter) ) .WhereIf(!input.Name.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Name)) .WhereIf(!input.UserName.IsNullOrWhiteSpace(), u => u.UserName.Contains(input.UserName)) .WhereIf(!input.PhoneNumber.IsNullOrWhiteSpace(), u => u.PhoneNumber.Contains(input.PhoneNumber)); if (!input.Permission.IsNullOrWhiteSpace()) { query = (from user in query join ur in _userRoleRepository.GetAll() on user.Id equals ur.UserId into urJoined from ur in urJoined.DefaultIfEmpty() join up in _userPermissionRepository.GetAll() on new { UserId = user.Id, Name = input.Permission } equals new { up.UserId, up.Name } into upJoined from up in upJoined.DefaultIfEmpty() join rp in _rolePermissionRepository.GetAll() on new { RoleId = ur.RoleId, Name = input.Permission } equals new { rp.RoleId, rp.Name } into rpJoined from rp in rpJoined.DefaultIfEmpty() where (up != null && up.IsGranted) || (up == null && rp != null) group user by user into userGrouped select userGrouped.Key); } return(query); }
public async Task <PagedResultDto <UserListDto> > GetUsers(GetUsersInput input) { var query = UserManager.Users .Include(u => u.Roles) .WhereIf(input.Role.HasValue, u => u.Roles.Any(r => r.RoleId == input.Role.Value)) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) ); if (!input.Permission.IsNullOrWhiteSpace()) { } var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var userListDtos = users.MapTo <List <UserListDto> >(); return(new PagedResultDto <UserListDto>( userCount, userListDtos )); }
/// <summary> /// 获取用户分页数据 /// </summary> /// <param name="input"></param> /// <returns></returns> public PagingList <UserDto> GetUsers(GetUsersInput input) { var query = _userRepository.Table; if (!string.IsNullOrWhiteSpace(input.NameKeyWords)) { query = query.Where(m => m.UserName.Contains(input.NameKeyWords) || m.NickName.Contains(input.NameKeyWords) || m.TrueName.Contains(input.NameKeyWords)); } if (!string.IsNullOrWhiteSpace(input.EmailAddress)) { query = query.Where(n => n.AccountEmail.Contains(input.EmailAddress)); } if (input.IsActive.HasValue) { query = query.Where(n => n.IsActived == input.IsActive.Value); } var source = query.OrderBy(n => n.Id) .Skip((input.PageIndex - 1) * input.PageSize) .Take(input.PageSize) .MapTo <List <UserDto> >(); var result = new PagingList <UserDto>(source, input.PageIndex, input.PageSize, query.LongCount()); return(result); }
public UserViewModel(IUserAppService appService, IRoleAppService roleAppService, IAccountService accountService, IProfileAppService profileAppService, IPermissionAppService permissionAppService) { IsAdvancedFilter = false; input = new GetUsersInput { Filter = "", MaxResultCount = AppConsts.DefaultPageSize, SkipCount = 0 }; roleList = new ObservableCollection<RoleListModel>(); this.appService = appService; this.roleAppService = roleAppService; this.accountService = accountService; this.profileAppService = profileAppService; this.permissionAppService = permissionAppService; AdvancedCommand = new DelegateCommand(() => { IsAdvancedFilter = !IsAdvancedFilter; }); SelectedCommand = new DelegateCommand(SelectedPermission); SearchCommand = new DelegateCommand(SearchUser); ResetCommand = new DelegateCommand(Reset); UpdateTitle(); dataPager.OnPageIndexChangedEventhandler += UsersOnPageIndexChangedEventhandler; }
public async Task <PagedResultOutput <UserListDto> > GetUsers(GetUsersInput input) { var query = UserManager.Users .Include(u => u.Roles) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) ); var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var userListDtos = users.MapTo <List <UserListDto> >(); await FillRoleNames(userListDtos); return(new PagedResultOutput <UserListDto>( userCount, userListDtos )); }
/// <summary> /// 用户管理 /// </summary> /// <param name="pageIndex">页码</param> /// <param name="pageSize">每页数据数</param> /// <returns></returns> public virtual ActionResult ManageUsers(int pageIndex = 1, int pageSize = 5) { #region 组装搜索条件 var input = new GetUsersInput { PageIndex = pageIndex, PageSize = pageSize, NameKeyWords = Request.QueryString.Get("NameKeyWords", string.Empty), EmailAddress = Request.QueryString.Get("EmailAddress", string.Empty), IsActive = Request.QueryString.Get <bool?>("IsActive", null) }; #endregion #region 组装搜索下拉列表 var activatedValues = new Dictionary <bool, string> { { true, "已激活" }, { false, "未激活" } }; ViewData["IsActived"] = new SelectList(activatedValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", input.IsActive); #endregion var user = _userService.GetUsers(input); return(View(user)); }
/* Is User Admin*/ public RequestOutput GetIsUserAdmin(GeneralInput input) { var query = _roleManager.Roles; var roles = query.ToList(); var requestOutput = new RequestOutput(); foreach (var role in roles) { if (role.Name.ToLower() == "admin") { var userInputDto = new GetUsersInput(); userInputDto.Filter = input.UserName; userInputDto.Role = role.Id; var queryUser = UserManager.Users .Where(u => u.Roles.Any(r => r.RoleId == role.Id)) .WhereIf(!input.UserName.IsNullOrWhiteSpace(), u => u.UserName.Contains(input.UserName)); var userCount = queryUser.Count(); if (userCount > 0) { requestOutput.Status = true; } requestOutput.StatusMessage = "SUCCESS"; break; } } return(requestOutput); }
public async Task <Result <ListResultDto <UserItemDto> > > GetUsers(GetUsersInput input) { List <UserItemDto> userDtos = new List <UserItemDto>(); var users = await _userManager.Users.ToListAsync(); foreach (var user in users) { bool userContains = false; foreach (var roleCombobox in input.RoleComboboxItems.Items) { if (roleCombobox.IsSelected) { userContains = await _userManager.IsInRoleAsync(user, roleCombobox.Value); if (userContains) { var userDto = await MapEntityToEntityDto(user); var firstedUserDto = userDtos.FirstOrDefault(user => user.Id == userDto.Id); if (firstedUserDto == null) { userDtos.Add(userDto); } } } } } return(Result <ListResultDto <UserItemDto> > .Success(new ListResultDto <UserItemDto>(userDtos))); }
public async Task <PagedResultDto <DelegatedUserListDto> > GetDelegatedUsers(GetUsersInput input) { var currentUserId = GetCurrentUser().Id; var query = from user in _userDelegationRepository.GetAll() join ur in _userRepository.GetAll() on user.UserId equals ur.Id into urJoined from ur in urJoined.DefaultIfEmpty() where user.DelegatedUserId == currentUserId select new DelegatedUserListDto() { Id = ur.Id, Name = ur.Name, UserName = ur.UserName, Surname = ur.Surname, FromDate = user.FromDate, ToDate = user.ToDate }; //var query = _userDelegationRepository.GetAll().Where(x => x.DelegatedUserId == GetCurrentUser().Id).Select(x => x.DelegatedUserFk); var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); //var userListDtos = ObjectMapper.Map<List<DelegatedUserListDto>>(users); return(new PagedResultDto <DelegatedUserListDto>( userCount, users )); }
public async Task <PaginationDto <UserDto> > GetUsers(GetUsersInput input) { var users = await _userRepository.GetAllListAsync(o => o.UserName != "admin"); if (!string.IsNullOrWhiteSpace(input.Key)) { users = users.Where(o => o.UserName.Contains(input.Key) || o.Mobile.Contains(input.Key) || o.Name.Contains(input.Key)).ToList(); } if (input.UserType > 0) { users = users.Where(o => o.UserType == (EnumUserType)input.UserType).ToList(); } if (!string.IsNullOrWhiteSpace(input.EmailAddress)) { users = users.Where(o => o.EmailAddress.Contains(input.EmailAddress)).ToList(); } if (input.IsActive > 0) { users = users.Where(o => o.IsActive == (input.IsActive == 1)).ToList(); } var userDtos = users.OrderByDescending(o => o.CreationTime).MapTo <List <UserDto> >(); return(userDtos.ToPagination(input)); }
/// <summary> /// 获取用户分页列表 /// </summary> public async Task <PagedResultDto <UserOutput> > GetUsers(GetUsersInput input) { var query = UserManager.Users .Include(u => u.Roles) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) ) .WhereIf( input.IsActive.HasValue, t => t.IsActive == input.IsActive.Value ); var userCount = await query.CountAsync(); var users = await query.OrderBy(input.Sorting).PageBy(input).ToListAsync(); var l = new PagedResultDto <UserOutput>( userCount, users.MapTo <List <UserOutput> >() ); return(l); }
/// <summary> /// 获取用户 分页 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <PagedResultDto <UserListDto> > GetUsers(GetUsersInput input) { var query = UserManager.Users .Include(u => u.Roles) .WhereIf(input.Role.HasValue, u => u.Roles.Any(r => r.RoleId == input.Role.Value)) .WhereIf( !input.Name.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Name) ) .WhereIf( !input.Phone.IsNullOrWhiteSpace(), u => u.PhoneNumber.Contains(input.Phone) ) ; var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var userListDtos = users.MapTo <List <UserListDto> >(); await FillRoleNames(userListDtos); return(new PagedResultDto <UserListDto>( userCount, userListDtos )); }
public async Task <PagedResultDto <UserProfileListDto> > GetUserProfiles(GetUsersInput input) { var query = GetUsersFilteredQuery(input); var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var userProfileListDtos = ObjectMapper.Map <List <UserProfileListDto> >(users); foreach (var userProfileListDto in userProfileListDtos) { if (userProfileListDto.ProfilePictureId != null) { userProfileListDto.ProfilePicture = await _profileAppService.GetProfilePictureByIdString(userProfileListDto.ProfilePictureId); } ; } await FillRoleProfileNames(userProfileListDtos); return(new PagedResultDto <UserProfileListDto>( userCount, userProfileListDtos )); }
public PagedResultOutput <UserDto> GetUsers(GetUsersInput input) { using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant)) { if (input.MaxResultCount <= 0) { input.MaxResultCount = SettingManager.GetSettingValue <int>(MySettingProvider.DefaultPageSize); } var userCount = _userRepository.Count(); var users = _userRepository .GetAll() .Include(q => q.CreatorUser) .OrderBy(input.Sorting) .PageBy(input); return(new PagedResultOutput <UserDto> { TotalCount = userCount, Items = users.MapTo <List <UserDto> >() }); } }
public async Task <PagedResultDto <UserListDto> > GetPaged(GetUsersInput input) { var query = UserManager.Users .WhereIf(input.Role != null && input.Role.Count > 0, u => u.Roles.Any(r => input.Role.Contains(r.RoleId))) .WhereIf(input.IsEmailConfirmed.HasValue, u => u.IsEmailConfirmed == input.IsEmailConfirmed) .WhereIf(input.IsActive.HasValue, u => u.IsActive == input.IsActive) .WhereIf(input.OnlyLockedUsers, u => u.LockoutEndDateUtc.HasValue && u.LockoutEndDateUtc.Value > DateTime.UtcNow) .WhereIf( !input.FilterText.IsNullOrWhiteSpace(), u => u.UserName.Contains(input.FilterText) || u.EmailAddress.Contains(input.FilterText) ); if (input.Permission != null && input.Permission.Count > 0) { query = from user in query join ur in _userRoleRepository.GetAll() on user.Id equals ur.UserId into urJoined from ur in urJoined.DefaultIfEmpty() join up in _userPermissionRepository.GetAll() on new { UserId = user.Id } } equals new { up.UserId } into upJoined from up in upJoined.DefaultIfEmpty() join rp in _rolePermissionRepository.GetAll() on new { ur.RoleId } equals new { rp.RoleId } into rpJoined from rp in rpJoined.DefaultIfEmpty() where (up != null && up.IsGranted || up == null && rp != null) && (input.Permission.Contains(up.Name) || input.Permission.Contains(rp.Name)) group user by user into userGrouped select userGrouped.Key; var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); try { var userListDtos = ObjectMapper.Map <List <UserListDto> >(users); await FillRoleNamesAsync(userListDtos); return(new PagedResultDto <UserListDto>( userCount, userListDtos )); } catch (Exception e) { Console.WriteLine(e); throw; } }
/// <summary> /// 查询用户列表 /// </summary> /// <param name="input"></param> /// <returns></returns> private async Task GetUsers(GetUsersInput filter) { await WebRequest.Execute(() => appService.GetUsers(filter), async result => { dataPager.SetList(result); await Task.CompletedTask; }); }
public JsonResult UserList(GetUsersInput input) { //var users = (await _userAppService.GetAll(new PagedResultRequestDto { MaxResultCount = int.MaxValue })).Items; //Paging not implemented yet input.PageIndex = input.SkipCount; input.SkipCount = (input.SkipCount - 1) * input.MaxResultCount; var result = _userAppService.GetUserByPage(input); return(AbpJson(new { code = 0, msg = string.Empty, count = result.TotalCount, data = result.Items }, wrapResult: false, behavior: JsonRequestBehavior.AllowGet)); }
public async Task <PagedResultDto <UserListDto> > GetUsers(GetUsersInput input) { var query = UserManager.Users .Include(u => u.Roles) .WhereIf(input.Role.HasValue, u => u.Roles.Any(r => r.RoleId == input.Role.Value)) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) ); if (!input.Permission.IsNullOrWhiteSpace()) { var isFilterPermissionGrantedByDefault = await PermissionChecker.IsGrantedAsync(input.Permission); query = (from user in query join ur in _userRoleRepository.GetAll() on user.Id equals ur.UserId into urJoined from ur in urJoined.DefaultIfEmpty() join up in _userPermissionRepository.GetAll() on new { UserId = user.Id, Name = input.Permission } equals new { up.UserId, up.Name } into upJoined from up in upJoined.DefaultIfEmpty() join rp in _rolePermissionRepository.GetAll() on new { RoleId = ur.RoleId, Name = input.Permission } equals new { rp.RoleId, rp.Name } into rpJoined from rp in rpJoined.DefaultIfEmpty() where (up != null && up.IsGranted) || ( up == null && ( rp != null || ( rp == null && isFilterPermissionGrantedByDefault ) ) ) group user by user into userGrouped select userGrouped.Key); } var userCount = await query.CountAsync(); var users = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); var userListDtos = users.MapTo <List <UserListDto> >(); await FillRoleNames(userListDtos); return(new PagedResultDto <UserListDto>( userCount, userListDtos )); }
public async Task <FileDto> GetUsersToExcel(GetUsersInput input) { IQueryable <User> query = QueryUser(input); var users = await query.ToListAsync(); var userListDtos = users.MapTo <List <UserListDto> >(); await FillRoleNames(userListDtos); return(new ExcelExporter().ExportToFile(userListDtos, _appFolders.TempFileDownloadFolder)); }
public async Task TestGetUsers() { var getUsersInput = new GetUsersInput(); var usersList = await _userAppService.GetUsersAsync(getUsersInput); Assert.True(usersList.Items.Count >= 0); getUsersInput.Filter = "qwerty"; var usersListEmpty = await _userAppService.GetUsersAsync(getUsersInput); Assert.True(usersListEmpty.Items.Count == 0); }
public IEnumerable <UserDto> GetUsers(GetUsersInput input) { var query = users.AsQueryable(); if (!string.IsNullOrWhiteSpace(input.Name)) { query = query.Where(m => m.Name.Contains(input.Name)); } var list = query.OrderBy(m => m.Id).Skip(input.PageIndex * input.PageSize).Take(input.PageSize).ToList(); return(list); }
private async Task <List <ComboboxItemDto> > GetUserList() { var input = new GetUsersInput(); var list = await _userAppService.GetUsers(input); var rlist = list.Items.Select(m => new ComboboxItemDto() { DisplayText = m.UserName, Value = m.Id.ToString() }).ToList(); rlist.Insert(0, new ComboboxItemDto("", "")); return(rlist); }
public GetUsersOutput GetUsers(GetUsersInput input) { //var output = new GetUsersOutput() //{ // Users = new List<UserDto> // { // new UserDto // { // Id = 1, // FirstName = "Emre", // LastName = "Kabaoğlu", // EmailAddress = "*****@*****.**", // EmployeeNumber = "EmployeeNumber", // Location = "Ankara" // }, // new UserDto // { // Id = 1, // FirstName = "Emre", // LastName = "Kabaoğlu", // EmailAddress = "*****@*****.**", // EmployeeNumber = "EmployeeNumber", // Location = "Ankara" // }, // new UserDto // { // Id = 1, // FirstName = "Emre", // LastName = "Kabaoğlu", // EmailAddress = "*****@*****.**", // EmployeeNumber = "EmployeeNumber", // Location = "Ankara" // }, // new UserDto // { // Id = 1, // FirstName = "Emre", // LastName = "Kabaoğlu", // EmailAddress = "*****@*****.**", // EmployeeNumber = "EmployeeNumber", // Location = "Ankara" // } // } //}; return(new GetUsersOutput { Users = _userService.GetUsers() }); }
public async Task <PagedResultOutput <UserListDto> > GetUsers(GetUsersInput input) { IQueryable <User> users = this.UserManager.Users; IQueryable <User> users1 = System.Data.Entity.QueryableExtensions.Include <User, ICollection <UserRole> >(users, (User u) => u.Roles); IQueryable <User> users2 = users1.WhereIf <User>(!input.Filter.IsNullOrWhiteSpace(), (User u) => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter)); int num = await users2.CountAsync <User>(); List <User> listAsync = await users2.OrderBy <User>(input.Sorting, new object[0]).PageBy <User>(input).ToListAsync <User>(); List <UserListDto> userListDtos = listAsync.MapTo <List <UserListDto> >(); await this.FillRoleNames(userListDtos); return(new PagedResultOutput <UserListDto>(num, userListDtos)); }
public async Task <IPagedList <UserListDto> > GetUsersAsync(GetUsersInput input) { var query = _userRepository.GetAll( !input.Filter.IsNullOrEmpty(), predicate => predicate.UserName.Contains(input.Filter) || predicate.Email.Contains(input.Filter)) .OrderBy(input.Sorting); var usersCount = await query.CountAsync(); var users = query.PagedBy(input.PageIndex, input.PageSize).ToList(); var userListDtos = _mapper.Map <List <UserListDto> >(users); return(userListDtos.ToPagedList(usersCount)); }
public PagedResultDto <UserListDto> UserAll(GetUsersInput input) { var count = _userRepository.GetAll().Count(); var listuser = _userRepository.GetAll() .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) ); ; return(new PagedResultDto <UserListDto>(count, listuser.MapTo <List <UserListDto> >())); }
public async Task <PagedResultDto <UserListDto> > GetUsers(GetUsersInput input) { var query = UserManager.Users .WhereIf(input.Role.HasValue, u => u.Roles.Any(r => r.RoleId == input.Role.Value)) .WhereIf(input.OnlyLockedUsers, u => u.LockoutEndDateUtc.HasValue && u.LockoutEndDateUtc.Value > DateTime.UtcNow) .WhereIf( !input.Filter.IsNullOrWhiteSpace(), u => u.Name.Contains(input.Filter) || u.Surname.Contains(input.Filter) || u.UserName.Contains(input.Filter) || u.EmailAddress.Contains(input.Filter) ); if (!input.Permission.IsNullOrWhiteSpace()) { query = from user in query join ur in _userRoleRepository.GetAll() on user.Id equals ur.UserId into urJoined from ur in urJoined.DefaultIfEmpty() join up in _userPermissionRepository.GetAll() on new { UserId = user.Id, Name = input.Permission } equals new { up.UserId, up.Name } into upJoined from up in upJoined.DefaultIfEmpty() join rp in _rolePermissionRepository.GetAll() on new { RoleId = ur == null ? 0 : ur.RoleId, Name = input.Permission } equals new { rp.RoleId, rp.Name } into rpJoined from rp in rpJoined.DefaultIfEmpty() where up != null && up.IsGranted || up == null && rp != null group user by user into userGrouped select userGrouped.Key; } var userCount = await query.CountAsync(); var users = query .OrderBy(input.Sorting) .PageBy(input) .ToList(); var userListDtos = ObjectMapper.Map <List <UserListDto> >(users); await FillRoleNames(userListDtos); return(new PagedResultDto <UserListDto>( userCount, userListDtos )); }