public IActionResult GetMovies(MoviesResourceParameters moviesResourceParameters) { var moviesFromRepo = _iIMDBRepository.GetMovies(moviesResourceParameters); var previousPageLink = moviesFromRepo.HasPrevious ? CreateMoviesResourceUri(moviesResourceParameters, ResourceUriType.PreviousPage) : null; var nextPageLink = moviesFromRepo.HasNext ? CreateMoviesResourceUri(moviesResourceParameters, ResourceUriType.NextPage) : null; var paginationMetadata = new { totalCount = moviesFromRepo.TotalCount, pageSize = moviesFromRepo.PageSize, currentPage = moviesFromRepo.CurrentPage, totalPages = moviesFromRepo.TotalPages, previousPageLink = previousPageLink, nextPageLink = nextPageLink }; Response.Headers.Add("X-Pagination", Newtonsoft.Json.JsonConvert.SerializeObject(paginationMetadata)); var movies = _mapper.Map <IEnumerable <MovieDto> >(moviesFromRepo); return(Ok(movies)); }
public ActionResult MovieIndex() { var movieData = DbRepository.GetMovies(); return(View(movieData)); }