コード例 #1
0
        public async Task <PagedList <User> > GetDeletedUsers(UserListParams userParams)
        {
            var userRequesting = await _context.Users.FirstOrDefaultAsync(u => u.Id == userParams.UserId);

            var users = _context.Users
                        .Include(p => p.OrganizationOwned)
                        .Include(p => p.Organization)
                        .Include(p => p.TeamsAssigned).ThenInclude(ta => ta.Team)
                        .OrderByDescending(u => u.FullName).AsQueryable();

            users = users.Where(u => u.OrganizationId == userRequesting.OrganizationId && u.IsDeleted);

            if (!string.IsNullOrEmpty(userParams.OrderBy))
            {
                switch (userParams.OrderBy)
                {
                case "created":
                    users = users.OrderByDescending(u => u.Created);
                    break;

                case "lastActive":
                    users = users.OrderByDescending(u => u.LastActive);
                    break;

                default:
                    users = users.OrderByDescending(u => u.FullName);
                    break;
                }
            }

            return(await PagedList <User> .CreateAsync(users, userParams.PageNumber, userParams.PageSize));
        }
コード例 #2
0
        public async Task <IActionResult> GetUsers([FromQuery] UserListParams userParams)
        {
            userParams.UserId = this.LoggedUser;
            var users = await _userRepo.GetUsers(userParams);

            var usersToReturn = _mapper.Map <IEnumerable <UserToListDTO> >(users);

            Response.AddPagination(users.CurrentPage, users.PageSize, users.TotalCount, users.TotalPages);

            return(Ok(usersToReturn));
        }