public ObjectResult Get(int page)
        {
            var upcomingMoviesModel     = _tmdbService.GetUpcomingMovies(page);
            var upcomingMoviesViewModel = _autoMapper.DefaultContext.Mapper.Map <UpcomingMoviesModel, UpcomingMoviesViewModel>(upcomingMoviesModel);

            return(Ok(upcomingMoviesModel));
        }
Exemplo n.º 2
0
        public async Task AddNextPageData()
        {
            try
            {
                if (Page == 0)
                {
                    UpcomingMovie.Clear();
                }

                if (Page <= TotalPages)
                {
                    Page++;
                    UpcomingMovieRequest upcomingMovie = new UpcomingMovieRequest()
                    {
                        page    = Page,
                        api_key = Settings.TMDbApiKey
                    };
                    UpcomingMovieResult upcomingMovies;

                    if (!String.IsNullOrWhiteSpace(Search))
                    {
                        upcomingMovie.query = Search;
                        upcomingMovies      = await _tMDbService.GetUpcomingMoviesSearchAsync(upcomingMovie);
                    }
                    else
                    {
                        upcomingMovies = await _tMDbService.GetUpcomingMovies(upcomingMovie);
                    }


                    TotalPages = upcomingMovies.TotalPages;
                    Page       = upcomingMovies.Page;
                    foreach (var item in upcomingMovies.Results)
                    {
                        item.Genres = await GetGenrer(item.GenreIds);

                        UpcomingMovie.Add(item);
                    }
                }
            }
            catch (ServiceAuthenticationException ex)
            {
                await _pageDialogService.DisplayAlertAsync("Error", "Some error occurs when try access the Server, please try again!", "OK");
            }
            catch (HttpRequestExceptionEx ex)
            {
                await _pageDialogService.DisplayAlertAsync("Error", "Service is not respond, please try again later!", "OK");
            }
            catch (Exception ex)
            {
                await _pageDialogService.DisplayAlertAsync("Error", "Unexpected error, please try again!", "OK");
            }
        }