public void TestCreateMovie() { Title title = new Title { TitleString = "Test Title", ReleaseYear = 2009, RuntimeInSeconds = 3600, AvgRating = 3, WhichSeason = "0", MaturityLevel =200, TvRating = "not set", LinkToPage = "www.netflix.com/test", IsMovie = "true" }; Movie result = Create.CreateMovie(title); Movie expected = new Movie { short_title = "Test Title", year = 2009, runtime = 3600, avg_rating = 3, is_movie = true, current_season = "0", maturity_rating = 200, movie_ID = 0, tv_rating= "not set", web_page = "www.netflix.com/test", }; Tools.TraceLine("result hash: {0}\nexpected hash: {1}", result.GetHashCode(), expected.GetHashCode()); Assert.AreEqual(result, expected); }
public static string Plot(Movie movie) { //make a call to omdb and get the plot string plot; string response_format = "xml"; var url = String.Format( @"http://www.omdbapi.com/?t={0}&y={1}&r={2}", movie.short_title, movie.year, response_format); //create the webrequest, add gzip encoding. HttpWebRequest web = (HttpWebRequest) WebRequest.Create(url); web.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; //get the response var resp = web.GetResponse(); var stream = resp.GetResponseStream(); //make sure there's actually a response if (stream != null) { StreamReader respStream = new StreamReader(stream); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(respStream.ReadToEnd()); //get the plot for the story, and then assign it to the FullView if (xDoc.InnerXml.Contains("Movie not") != true) { plot = xDoc.GetElementsByTagName("movie")[0].Attributes["plot"] .Value; Tools.TraceLine("The plot is: {0}", plot); } else { plot = @"N/A"; Tools.TraceLine("The plot is: {0}", plot); } } else { plot = @"N/A"; } return plot; }
public ActionResult Edit(Movie movie) { MovieDbContext db = new MovieDbContext(); if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("oldIndex"); } return View(movie); }
public ActionResult Create(Movie movie) { MovieDbContext db = new MovieDbContext(); if (ModelState.IsValid) { db.Movies.Add(movie); db.SaveChanges(); return RedirectToAction("oldIndex"); } return View(movie); }
public bool Equals(Movie movie) { // If parameter is null return false: if ((object)movie == null) { return false; } // Return true if the fields match: return (//this.movie_ID == movie.movie_ID && this.short_title == movie.short_title && this.year == movie.year && this.runtime == movie.runtime && this.avg_rating == movie.avg_rating && this.tv_rating == movie.tv_rating && this.web_page == movie.web_page && this.current_season == movie.current_season && this.maturity_rating == movie.maturity_rating ); }
/// <summary> /// iterate over all the genres in Title and add them to the movie ID /// </summary> /// <param name="movie"></param> /// <param name="title"></param> /// <returns></returns> public static MovieToGenre CreateMovieMovieToGenre(Movie movie, Genre genre) { //find the Genre equivalent of genre MovieToGenre movieToGenre = new MovieToGenre { genre_ID = genre.genre_ID, movie_ID = movie.movie_ID }; return movieToGenre; }
//creates a row of box art data and assigns to to the movie id its title was from public static BoxArt CreateMovieBoxartFromTitle(Movie movie, Title title) { BoxArt boxArt = new BoxArt { movie_ID = movie.movie_ID, boxart_38 = title.BoxArt38, boxart_64 = title.BoxArt64, boxart_110 = title.BoxArt110, boxart_124 = title.BoxArt124, boxart_150 = title.BoxArt150, boxart_166 = title.BoxArt166, boxart_88 = title.BoxArt88, boxart_197 = title.BoxArt197, boxart_176 = title.BoxArt176, boxart_284 = title.BoxArt284, boxart_210 = title.BoxArt210 }; return boxArt; }
//will turn a Title into a Movie which can be used for the site. public static Movie CreateMovie(Title title) { //I can actually see this conversion process actually being //difficult to keep up, if the data model changes but for now, it's //all we got. bool is_a_movie = true; //test for isMovie if (title.WhichSeason == "0") { is_a_movie = true; } else { is_a_movie = false; } //create movie instance Movie movie = new Movie { short_title = title.TitleString, year = title.ReleaseYear, runtime = title.RuntimeInSeconds, avg_rating = title.AvgRating, tv_rating = title.TvRating, web_page = title.LinkToPage, current_season = title.WhichSeason, is_movie = is_a_movie, maturity_rating = title.MaturityLevel, }; //CreateMovieBoxartFromTitle(movie, title); return movie; }
public void TestMovieEquals() { Movie first_movie = new Movie { year = 1999, maturity_rating = 200, runtime = 12345 }; Movie second_movie = new Movie { year = 1999, maturity_rating = 200, runtime = 12345 }; Assert.AreEqual(first_movie, second_movie); Assert.AreNotEqual(first_movie, new Movie()); Assert.AreNotEqual(second_movie, new Movie()); }