Exemplo n.º 1
0
 public Title Post([FromBody]JObject jObject)
 {
     string imdbId = (string)jObject["imdbId"];
     TitleDetailsResponse titleDetails = titleService.GetTitleDetailsFromTmdb(imdbId);
     Title title = titleService.ParseTitle(titleDetails);
     titleRepository.Add(title);
     List<TitleCredit> titleCredits = personService.GetTitleCredits(title.Id, title.TmdbId);
     titleCreditRepository.AddRange(titleCredits);
     return title;
 }
Exemplo n.º 2
0
 public Title ParseTitle(TitleDetailsResponse titleDetails)
 {
     return(new Title
     {
         ImdbId = titleDetails.imdb_id,
         TmdbId = tmdbId,
         Name = titleDetails.original_title,
         PosterUrl = titleDetails.poster_path,
         Runtime = titleDetails.runtime
     });
 }
Exemplo n.º 3
0
        public TitleDetailsResponse GetTitleDetailsFromTmdb(string imdbId)
        {
            tmdbId = GetTmdbId(imdbId);
            string url = $"https://api.themoviedb.org/3/movie/{tmdbId}?api_key={apiKey}&language=us-US";

            using WebClient webClient = new WebClient();
            string json_data = string.Empty;

            json_data = webClient.DownloadString(url);
            TitleDetailsResponse response = JsonConvert.DeserializeObject <TitleDetailsResponse>(json_data);

            return(response);
        }