public async Task <ImdbMainServiceModel> GetMovieDataAsync(string movieTitleId) { string contentFilePath = GlobalConstants.MainContentImdbLogFilePath; string mainContentUrl = string.Format(GlobalConstants.ImdbMainContentUrl, movieTitleId); this.docMain = await GetDocNode(contentFilePath, mainContentUrl); (int productionYear, string title) = await Task.Run(() => this.GetProductionYearAndTitle()); var model = new ImdbMainServiceModel { //Awards = await Task.Run(() => this.GetAwards(movieTitleId)), Cast = await Task.Run(() => this.GetCast()), Colors = await Task.Run(() => this.GetZebraListValues("Color")), Countries = await Task.Run(() => this.GetZebraListValues("Country")), Crew = await Task.Run(() => this.GetCrew()), Genres = await Task.Run(() => this.GetZebraListValues("Genre")), ImdbId = movieTitleId, ImdbTop250 = await Task.Run(() => this.GetTop250()), ImdbUsersRating = await Task.Run(() => this.GetUsersRating()), Languages = await Task.Run(() => this.GetZebraListValues("Language")), OriginalTitle = await Task.Run(() => this.GetOriginalTitle()), ProductionYear = productionYear, //Releases = await Task.Run(() => this.GetReleaseInfo(movieTitleId)), Runtime = await Task.Run(() => this.GetRuntime("Runtime")), Studios = await Task.Run(() => this.GetStudios()), Synopsis = await Task.Run(() => this.GetSynopsis()), Title = title }; //this.DownloadPoster(); return(model); }
public async Task<IActionResult> Search(MovieSearchTitleFormModel formSearchModel) { const string none = WebConstants.RadioButtonNoneValue; string blurayDotComTitleId = formSearchModel.BlurayDotComSelectedTitle; string boxOfficeMojoTitleId = formSearchModel.BoxOfficeMojoSelectedTitle; string dvdEmpireTiteId = formSearchModel.DvdEmpireSelectedTitle; string imdbTitleId = formSearchModel.ImdbSelectedTitle; string rottenTomatoesTitleId = formSearchModel.RottenTomattoesSelectedTitle; MovieFormMainModel formMainModel = new MovieFormMainModel(); #region Blu-ray.com if (!string.IsNullOrEmpty(blurayDotComTitleId) && blurayDotComTitleId != none) { //BlurayDotComMainServiceModel blurayDotComServiceModel // = await this.blurayDotComService.GetMovieDataAsync(blurayDotComTitleId); } #endregion Blu-ray.com #region Box Office Mojo if (!string.IsNullOrEmpty(boxOfficeMojoTitleId) && boxOfficeMojoTitleId != none) { try { BoxOfficeMojoMainServiceModel boxOfficeMojoServiceModel = await this.boxOfficeMojoService.GetMovieDataAsync(boxOfficeMojoTitleId); IMapper config = new MapperConfiguration(cfg => { cfg.CreateMap<BoxOfficeMojoMainServiceModel, MovieFormMainModel>(); }) .CreateMapper(); config.Map(boxOfficeMojoServiceModel, formMainModel); } catch (Exception ex) { await Task.Run(() => ex.Log(nameof(HomeController), nameof(Search))); } } #endregion Box Office Mojo #region IMDb if (!string.IsNullOrEmpty(imdbTitleId) && imdbTitleId != none) { try { ImdbMainServiceModel imdbServiceModel = await this.imdbService.GetMovieDataAsync(imdbTitleId); this.mapper.Map(imdbServiceModel, formMainModel); IEnumerable<string> colorNames = imdbServiceModel.Colors; formMainModel.SelectedColors = await this.movieDbService.GetColorsIdFromNameAsync(colorNames); IEnumerable<string> countryNames = imdbServiceModel.Countries; formMainModel.SelectedCountries = await this.movieDbService.GetCountriesIdFromNameAsync(countryNames); IEnumerable<string> genreNames = imdbServiceModel.Genres; formMainModel.SelectedGenres = await this.movieDbService.GetGenresIdFromNameAsync(genreNames); IEnumerable<string> languageNames = imdbServiceModel.Languages; formMainModel.SelectedLanguages = await this.movieDbService.GetLanguagesIdFromNameAsync(languageNames); } catch (Exception ex) { await Task.Run(() => ex.Log(nameof(HomeController), nameof(Search))); } } #endregion IMDb #region Rotten Tomattoes if (!string.IsNullOrEmpty(rottenTomatoesTitleId) && rottenTomatoesTitleId != none) { try { RottenTomatoesMainServiceModel rottenTomatoesServiceModel = await this.rottenTomatoesService.GetMovieDataAsync(rottenTomatoesTitleId); IMapper config = new MapperConfiguration(cfg => { cfg.CreateMap<RottenTomatoesMainServiceModel, MovieFormMainModel>(); }) .CreateMapper(); config.Map(rottenTomatoesServiceModel, formMainModel); } catch (Exception ex) { await Task.Run(() => ex.Log(nameof(HomeController), nameof(Search))); } } #endregion Rotten Tomattoes await this.PopulateFormMainModel(formMainModel); return View("Edit", formMainModel); }