public async Task <PagedResultDto <NameValueDto> > FindUsersAsync(FindOrganizationUnitUsersInput input)
        {
            var userIdsInOrganizationUnit = (await _organizationUnitUserRepository.FindOrganizationUnitUsersAsync(input.OrganizationUnitId).ConfigureAwait(false))
                                            .Select(uou => uou.UserId);
            var query = _userManager.Users
                        .Where(u => !userIdsInOrganizationUnit.Contains(u.Id))
                        .WhereIf(
                !input.Filter.IsNullOrWhiteSpace(),
                u =>
                u.UserName.Contains(input.Filter) ||
                u.Name.Contains(input.Filter)
                );
            var userCount = await _organizationUnitUserRepository.GetCountAsync();

            var users = query
                        .OrderBy(u => u.Name)
                        .PageBy(input)
                        .ToList();

            return(new PagedResultDto <NameValueDto>(
                       userCount,
                       users.Select(u =>
                                    new NameValueDto(
                                        u.Name,
                                        u.Id.ToString()
                                        )
                                    ).ToList()
                       ));
        }
예제 #2
0
 public async Task <PagedResultDto <NameValueDto> > FindUsersAsync(FindOrganizationUnitUsersInput input)
 {
     return(await _organizationUnitUserAppService.FindUsersAsync(input));
 }