Exemple #1
0
        public async Task <List <Movie> > getFilmWorldMovies()
        {
            List <Movie> movieList;

            try
            {
                using (var response = await _httpClient.GetAsync("api/filmworld/movies"))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        FilmWorld output = JsonSerializer.Deserialize <FilmWorld>(apiResponse, _jsonOptions);
                        movieList = await getFilmWorldMoviesDetails(output.movies);
                    }
                    else
                    {
                        movieList = new List <Movie>();
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation("An error occurred: ", ex.Message);
                return(new List <Movie>());
            }
            return(movieList);
        }
Exemple #2
0
        public Intermediary(CinemaWorld cinemaWorld, FilmWorld filmWorld)
        {
            CinemaWorldProv = cinemaWorld;
            filmWorldProv   = filmWorld;

            allProviders = new List <MiddleWareTech> {
                CinemaWorldProv, filmWorldProv
            };
        }
Exemple #3
0
        public void Test9()
        {
            var          config      = InitConfiguration();
            Provider     provider    = Provider.FilmWorld;
            string       id          = "-1op,l;";
            CinemaWorld  cinemaWorld = new CinemaWorld(config.GetSection("CinemaWorldApi").Value, config.GetSection("CinemaWorldAccessToken").Value);
            FilmWorld    filmWorld   = new FilmWorld(config.GetSection("FilmWorldApi").Value, config.GetSection("FilmWorldAccessToken").Value);
            Intermediary im          = new Intermediary(cinemaWorld, filmWorld);
            Decimal      price       = im.MoviePrice(provider, id).Result;

            Assert.AreEqual(-1, price);
        }
Exemple #4
0
        public void Test3()
        {
            var config = InitConfiguration();
            IEnumerable <MovieSummary> movies;
            CinemaWorld  cinemaWorld = new CinemaWorld(config.GetSection("CinemaWorldApi").Value, config.GetSection("CinemaWorldAccessToken").Value);
            FilmWorld    filmWorld   = new FilmWorld(config.GetSection("FilmWorldApi").Value, config.GetSection("FilmWorldAccessToken").Value);
            Intermediary im          = new Intermediary(cinemaWorld, filmWorld);

            movies = im.FindMovies("new hope").Result;

            List <MovieSummary> movieList = movies.ToList();
            int count = movieList.Count();

            Assert.AreEqual(2, count);
        }
Exemple #5
0
        public void Test5()
        {
            var config = InitConfiguration();
            IEnumerable <MovieSummary> movies;
            CinemaWorld  cinemaWorld = new CinemaWorld(config.GetSection("CinemaWorldApi").Value, config.GetSection("CinemaWorldAccessToken").Value);
            FilmWorld    filmWorld   = new FilmWorld(config.GetSection("FilmWorldApi").Value, config.GetSection("FilmWorldAccessToken").Value);
            Intermediary im          = new Intermediary(cinemaWorld, filmWorld);

            movies = im.FindMovies("John wick").Result;

            List <MovieSummary> movieList = movies.ToList();
            var ret   = movieList.Where(m => m.Title.ToLower().Contains("John Wick".ToLower(), StringComparison.OrdinalIgnoreCase)).ToList();
            int count = ret.Count();

            Assert.AreEqual(0, count);
        }
 public IActionResult GetMoviePrice(Provider provider, String id)
 {
     try
     {
         Decimal      price;
         CinemaWorld  cinemaWorld = new CinemaWorld(Configuration.GetSection("CinemaWorldApi").Value, Configuration.GetSection("CinemaWorldAccessToken").Value);
         FilmWorld    filmWorld   = new FilmWorld(Configuration.GetSection("FilmWorldApi").Value, Configuration.GetSection("FilmWorldAccessToken").Value);
         Intermediary im          = new Intermediary(cinemaWorld, filmWorld);
         price = im.MoviePrice(provider, id).Result;
         return(Ok(price));
     }
     catch (Exception ex)
     {
         return(new JsonResult(new { message = "Price for the movie not found" })
         {
             StatusCode = 500
         });
     }
 }
 public IActionResult GetMovie(String searchTerm)
 {
     try
     {
         IEnumerable <MovieSummary> movies;
         CinemaWorld  cinemaWorld = new CinemaWorld(Configuration.GetSection("CinemaWorldApi").Value, Configuration.GetSection("CinemaWorldAccessToken").Value);
         FilmWorld    filmWorld   = new FilmWorld(Configuration.GetSection("FilmWorldApi").Value, Configuration.GetSection("FilmWorldAccessToken").Value);
         Intermediary im          = new Intermediary(cinemaWorld, filmWorld);
         movies = im.FindMovies(searchTerm).Result;
         return(Ok(movies));
     }
     catch (Exception ex)
     {
         return(new JsonResult(new { message = "Movie Not Found" })
         {
             StatusCode = 500
         });
     }
 }