public ActionResult _Fav(string ID) { List <string> errors = new List <string>(); // You might want to return an error if something wrong happened FavouriteMovie favMovieData = new FavouriteMovie(); favMovieData.MovieId = ID; favMovieData.UserId = User.Identity.GetUserId(); try { int movieID = int.Parse(ID); TMDbClient client = new TMDbClient("a331c3f9e48b75412c7c99a04a4aba78"); client = MovieDatabase.FetchConfig(client); Movie movie = client.GetMovieAsync(movieID, MovieMethods.Videos).Result; string xmlMovieInfo = MovieDatabase.GetXMLFromObject(movie); var xmlData = XElement.Parse(xmlMovieInfo); favMovieData.MovieInfo = xmlData; } catch (Exception ex) { errors.Add(ex.ToString()); } db.FavouriteMovies.Add(favMovieData); db.SaveChanges(); return(Json(errors, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { TMDbClient client = new TMDbClient("a331c3f9e48b75412c7c99a04a4aba78"); client = MovieDatabase.FetchConfig(client); var results = client.DiscoverMoviesAsync().WhereAnyReleaseDateIsInYear(DateTime.Now.Year).OrderBy(TMDbLib.Objects.Discover.DiscoverMovieSortBy.PopularityDesc).Query().Result.Results; ViewBag.Results = results; string currentUserId = User.Identity.GetUserId(); ViewBag.Favourites = db.FavouriteMovies.Where(x => x.UserId == currentUserId).Select(x => x.MovieId).ToList(); return(View()); }
public ActionResult Index(string search) { TMDbClient client = new TMDbClient("a331c3f9e48b75412c7c99a04a4aba78"); client = MovieDatabase.FetchConfig(client); var results = client.SearchMovieAsync(search).Result.Results; ViewBag.SearchTerm = search; ViewBag.Results = results; string currentUserId = User.Identity.GetUserId(); ViewBag.Favourites = db.FavouriteMovies.Where(x => x.UserId == currentUserId).Select(x => x.MovieId).ToList(); return(View()); }
public ActionResult Index() { TMDbClient client = new TMDbClient("a331c3f9e48b75412c7c99a04a4aba78"); client = MovieDatabase.FetchConfig(client); Movie latestMovie = MovieDatabase.FetchFeaturedMovie(client); ViewBag.Movie = latestMovie; ViewBag.Poster = "https://image.tmdb.org/t/p/w342" + latestMovie.PosterPath; if (latestMovie.Videos.Results.Count > 0) { ViewBag.ButtonLink = "https://www.youtube.com/embed/" + latestMovie.Videos.Results[0].Key; ViewBag.ButtonText = "Check out the Trailer »"; } else { ViewBag.ButtonLink = latestMovie.Homepage; ViewBag.ButtonText = "Check out the Website »"; } return(View()); }