コード例 #1
0
        public async void Should_Get_Users()
        {
            var userListInput = new UserListInput();
            var userList      = await _userAppService.GetUsersAsync(userListInput);

            Assert.True(userList.Items.Count > 0);

            userListInput.Filter = ".!1Aa_";
            var usersListEmpty = await _userAppService.GetUsersAsync(userListInput);

            Assert.True(usersListEmpty.Items.Count == 0);
        }
コード例 #2
0
        public async Task <IPagedList <UserListOutput> > GetUsersAsync(UserListInput input)
        {
            var query = _userManager.Users.Where(
                !input.Filter.IsNullOrEmpty(),
                predicate => predicate.UserName.Contains(input.Filter) ||
                predicate.Email.Contains(input.Filter))
                        .OrderBy(input.SortBy);

            var usersCount = await query.CountAsync();

            var users          = query.PagedBy(input.PageIndex, input.PageSize).ToList();
            var userListOutput = _mapper.Map <List <UserListOutput> >(users);

            return(userListOutput.ToPagedList(usersCount));
        }
コード例 #3
0
ファイル: UserService.cs プロジェクト: Gl-lab/PathfinderStore
        public async Task <IPagedList <UserListOutput> > GetUsersAsync(UserListInput input)
        {
            var query = _userManager.Users.Where(
                predicate => predicate.UserName.Contains(input.FilteringOptions[0].Value as string) ||
                predicate.Email.Contains(input.FilteringOptions[0].Value as string))
                        .OrderBy(input.SortingOptions?.Count > 0 ? "UserName" : input.SortingOptions[0].Field);
            var usersCount = await query.CountAsync().ConfigureAwait(false);

            IEnumerable <UserListOutput> userListOutput =
                _mapper.Map <List <UserListOutput> >(query.ToArrayAsync().ConfigureAwait(false));
            var pageCount = usersCount / input.PageSize;

            return(new PagedList <UserListOutput>(input.PageIndex, input.PageSize, usersCount, pageCount,
                                                  userListOutput));
        }
コード例 #4
0
 public async Task <ActionResult <IPagedList <UserListOutput> > > GetUsers(UserListInput input)
 {
     return(Ok(await _userService.GetUsersAsync(input)));
 }