Пример #1
0
        public async Task <Pagination <UserInfo> > SearchUsersAsync(UserFilterInput filter)
        {
            using (_dbContextScopeFactory.CreateReadOnly())
            {
                var users = await GetAllUserInfoAsync();

                int count = users.Count;
                if (!string.IsNullOrEmpty(filter.Key))
                {
                    count = _userInfos.Count(user => user.SearchText.Contains(filter.Key));
                }
                if (count == 0)
                {
                    return(new Pagination <UserInfo>(0, new List <UserInfo>()));
                }
                int skip        = (filter.Page - 1) * filter.PageSize;
                int take        = filter.PageSize;
                var searchUsers = _userInfos
                                  .Where(user => user.SearchText.Contains(filter.Key))
                                  .Skip(skip)
                                  .Take(take)
                                  .ToList();
                return(new Pagination <UserInfo>(count, searchUsers, skip, take));
            }
        }
Пример #2
0
        public IActionResult MainListPartial()
        {
            UserFilterInput           filterInput  = GetFilterInSession <UserFilterInput>(ConstantConfig.SessionName.UserSession);
            PagingResultDto <UserDto> pagingResult = userService.GetAllByPaging(filterInput);

            return(PartialView(pagingResult));
        }
Пример #3
0
        public async Task <PageResult <UserVm> > GetUsers(UserFilterInput filter)
        {
            var result = await _client.GetUsers.ExecuteAsync(filter);

            if (result.IsErrorResult())
            {
                _snackbar.Add(string.Join('\n', result.Errors.Select(x => x.Message)), Severity.Error);
            }
            return(new PageResult <UserVm>(result.Data.Users));
        }
Пример #4
0
        public IActionResult GetAll(UserFilterInput filterInput = null)
        {
            if (filterInput == null)
            {
                filterInput = new UserFilterInput();
            }

            var result = userService.GetAllByPaging(filterInput);

            return(Ok(result));
        }
Пример #5
0
        public IActionResult Index(int pageIndex = 1)
        {
            UserFilterInput filterInput = GetFilterInSession <UserFilterInput>(ConstantConfig.SessionName.UserSession);

            filterInput.PageNumber = pageIndex;
            UserViewModel userViewModel = new UserViewModel
            {
                FilterInput  = filterInput,
                PagingResult = userService.GetAllByPaging(filterInput)
            };

            InitAdminBaseViewModel(userViewModel);
            return(View(userViewModel));
        }
Пример #6
0
        public PagingResultDto <UserDto> GetAllByPaging(UserFilterInput filterInput)
        {
            SetDefaultPageSize(filterInput);

            IQueryable <WebCoreUser> userQuery = userRepository.GetAll();

            userQuery = userQuery.Filter(filterInput);

            PagingResultDto <UserDto> userResult = userQuery
                                                   .ProjectTo <UserDto>(mapper.ConfigurationProvider)
                                                   .PagedQuery(filterInput);

            return(userResult);
        }
Пример #7
0
        public async Task <UserPoco[]> GetFilteredUsers(UserFilterInput input)
        {
            try
            {
                var result          = new List <UserPoco>();
                var beginningOfTime = new DateTime();
                switch (input.Filter)
                {
                case UserFilter.LockedOut:
                    result = await _context.Users.Where(x => x.LockoutEnd > DateTimeOffset.UtcNow).ToListAsync();

                    break;

                case UserFilter.NeverLoggedIn:
                    result = await _context.Users.Where(x => x.LastLoggedIn == beginningOfTime).ToListAsync();

                    break;

                case UserFilter.LoggedInLastMonth:
                    result = await _context.Users.Where(x => x.LastLoggedIn == beginningOfTime).ToListAsync();

                    break;

                case UserFilter.LoggedIn:
                    result = await _context.Users.Where(x => x.LastLoggedIn < (DateTime.Today.AddMonths(-1))).ToListAsync();

                    break;

                default:
                    result = null;
                    break;
                }
                return(result.ToArray());
            }
            catch
            {
                return(null);
            }
        }
Пример #8
0
 public IActionResult FilterPartial(UserFilterInput filterInput)
 {
     SetFilterToSession(ConstantConfig.SessionName.UserSession, filterInput);
     return(RedirectToAction("Index", new { page = 1 }));
 }
Пример #9
0
        public async Task <JsonResult> GetFilteredUserList([FromBody] UserFilterInput input)
        {
            var result = await _user.GetFilteredUsers(input);

            return(await GenerateResult(result, _userSettings));
        }