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"); } }
public async Task <UpcomingMovieResult> GetUpcomingMoviesSearchAsync(UpcomingMovieRequest upcomingMovieRequest) { try { var uri = UriHelper.CombineUri(Settings.TMDbBaseEndpoint, UpcomingSearchURL); string queryString = _requestProvider.ConvertQueryString(upcomingMovieRequest); return(await _requestProvider.GetAsync <UpcomingMovieResult>(uri + queryString)); } catch (System.Exception ex) { return(new UpcomingMovieResult()); } }