Пример #1
0
        public async Task <ActionResult <IEnumerable <Flight> > > GetAllFlights([FromQuery] FlightQueryParameters parameters)
        {
            var flights = await _repository.GetAllAsync(parameters);

            var metadata = new
            {
                ((PaginatedList <Flight>)flights).ItemCount,
                parameters.PageSize,
                ((PaginatedList <Flight>)flights).PageIndex,
                ((PaginatedList <Flight>)flights).TotalPages,
                ((PaginatedList <Flight>)flights).HasNextPage,
                ((PaginatedList <Flight>)flights).HasPreviousPage
            };


            Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata));

            return(Ok(_mapper.Map <IEnumerable <FlightReadDto> >(flights)));
        }