public async Task <ActionResult <IEnumerable <UserDto> > > GetUsers([FromQuery] PaginationFilter filter) { List <UserDto> users = new List <UserDto>(); var route = Request.Path.Value; var validFilter = new PaginationFilter(filter.PageNumber, filter.PageSize); var totalElements = await _context.Users.CountAsync(); if (totalElements == 0) { return(NotFound(new PagedResponse <List <UserDto> >() { Message = "NO HAY RESULTADOS CON LOS PARAMETROS INDICADOS", ErrorCode = 416 })); } else { var result = await _context.Users .Skip((validFilter.PageNumber - 1) *validFilter.PageSize) .Take(validFilter.PageSize) .Include(u => u.Role) .ToListAsync(); result.ForEach(u => users.Add(_mapper.Map <UserDto>(u))); PagedResponse <List <UserDto> > pagedResponse = Pagination.CreatePagedReponse <UserDto>(users, validFilter, totalElements, _uriService, route); return(Ok(pagedResponse)); } }