Пример #1
0
        public async Task <ResultDTO <MovieEntity> > GetNowPlayingMovies(string language, int page)
        {
            var moviesNowPlayingAPI      = RestService.For <IMoviesApi>(Endpoints.BaseEirpointHttpClient());
            var moviesNowPlayingResponse = await moviesNowPlayingAPI.GetNowPlayingMovies(Endpoints.BaseTheMovieDbApiKey, language, page);

            if (moviesNowPlayingResponse.IsSuccessStatusCode)
            {
                var response = await moviesNowPlayingResponse.Content.ReadAsStringAsync();

                var json = await Task.Run(() => JsonConvert.DeserializeObject <ResultDTO <MovieEntity> >(response));

                //update paths
                UpdateRelativePaths(json.Results);

                return(json);
            }

            return(new ResultDTO <MovieEntity>());
        }
Пример #2
0
        public async Task <List <MovieEntity> > GetSearchedMovies(string textSearch, string language, int page)
        {
            var query               = System.Net.WebUtility.UrlEncode(textSearch);
            var moviesQueryAPI      = RestService.For <IMoviesApi>(Endpoints.BaseEirpointHttpClient());
            var moviesQueryResponse = await moviesQueryAPI.GetMoviesByQuery(Endpoints.BaseTheMovieDbApiKey, language, query, page);

            if (moviesQueryResponse.IsSuccessStatusCode)
            {
                var response = await moviesQueryResponse.Content.ReadAsStringAsync();

                var json = await Task.Run(() => JsonConvert.DeserializeObject <ResultDTO <MovieEntity> >(response));

                //update paths
                UpdateRelativePaths(json.Results);

                return(json.Results);
            }

            return(new List <MovieEntity>());
        }