public IActionResult GetPeople([FromQuery] PeopleParameters peopleParameters) { IPaginationMetadata metadata = new PaginationMetadata(peopleParameters.MaxPageSize, peopleParameters.PageNumber, peopleParameters.PageSize); Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(_peopleDataAccess.GetByPaginationParameters(peopleParameters.PageNumber, peopleParameters.PageSize))); }
public IActionResult GetAllPeople([FromQuery] PeopleParameters peopleParams) { var allPeople = _personService.GetAllPeople(peopleParams); var metadata = new { allPeople.TotalCount, allPeople.PageSize, allPeople.CurrentPage, allPeople.HasNext, allPeople.HasPrevious }; // Can be used from a front end UI to set up pagination Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(allPeople)); }
// <summary> // Returns a list of all people in the datastore from repository // </summary> // param name="peopleParameters"> Parameters supplied in the request query string to allow people results to be filtered // <returns> // Returns PageList object of all people // </returns> public PageList <Person> GetAllPeople(PeopleParameters peopleParameters) { return(PageList <Person> .ToPagedList(_personRepository.GetAll(), peopleParameters.PageNumber, peopleParameters.PageSize)); }