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);
        }
        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));
        }
        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));
        }
 public async Task <ActionResult <IPagedList <UserListOutput> > > GetUsers(UserListInput input)
 {
     return(Ok(await _userService.GetUsersAsync(input)));
 }