public async Task <IActionResult> Details(int movieScheduleId) { var model = new MovieDetailsModel { Movie = _movieScheduleRepository.Find(movieScheduleId) }; var imdbData = await _imdbService.GetMovie(model.Movie.Movie.ImdbId); if (!string.IsNullOrEmpty(imdbData.Error)) { return(RedirectToAction("Error", "Public")); } model.Rate = float.Parse(imdbData.ImdbRating); model.Categories = imdbData.Genre.Split(','); model.Duration = TimeSpan.FromMinutes(int.Parse(imdbData.RunTime.Replace("min", string.Empty).Trim())); model.ImageSource = imdbData.Poster; model.Reviews = model.Movie.Movie.Reviews.OrderByDescending(mr => mr.CreatedAt).ToArray(); var searcher = new VideoSearch(); var video = searcher.SearchQuery(model.Movie.Movie.Name, 1).FirstOrDefault(); if (video != null) { model.Trailer = TransformUrlToEmbed(video.Url); } return(View(model)); }