public MovieModel(dynamic movie) { NetflixMovy nm = new NetflixMovy(); nm.NetflixID = movie.Id; nm.Title = movie.Name; nm.ReleaseYear = movie.ReleaseYear; nm.Rating = movie.Rating; nm.Synopsis = movie.Synopsis; nm.ShortSynopsis = movie.ShortSynopsis; nm.AverageRating = movie.AverageRating; nm.Type = movie.Type; if( movie.Runtime != null) nm.Runtime = movie.Runtime; if( movie.Instant != null) nm.ExpiresDate = movie.Instant.AvailableTo; if( movie.BoxArt != null) nm.LargeUrl = movie.BoxArt.LargeUrl; string[] apiParts = movie.NetflixApiId.Split('/'); nm.ApiId = int.Parse(apiParts[apiParts.Count() - 1]); _netflix = nm; _rottenTomato = null; }
private void detach_RtMovies(RtMovy entity) { this.SendPropertyChanging(); entity.NetflixMovy = null; }
partial void DeleteRtMovy(RtMovy instance);
partial void UpdateRtMovy(RtMovy instance);
partial void InsertRtMovy(RtMovy instance);
private List<MovieModel> SetupRottenTomatoRatings(List<MovieModel> movies) { List<MovieModel> movieData = new List<MovieModel>(); MoviesDBDataContext db = new MoviesDBDataContext(); foreach (var m in movies) { RtMovy rtMovie = null; if (m.Netflix.Type == "Movie")//type = movie { int id = m.Netflix.MovieID; rtMovie = (from movie in db.RtMovies where movie.MovieID == id select movie).FirstOrDefault(); if (rtMovie == null) { Movie rt = RottenTomatoes.SearchMoviesByTitle(m.Netflix.Title, m.Netflix.ReleaseYear.ToString()); if (rt != null) { rtMovie = new RtMovy(); rtMovie.MovieID = m.Netflix.MovieID; var a = rt.Ratings.Where(r => r.Type == "audience_rating").FirstOrDefault(); var b = rt.Ratings.Where(r => r.Type == "audience_score").FirstOrDefault(); var c = rt.Ratings.Where(r => r.Type == "critics_rating").FirstOrDefault(); var d = rt.Ratings.Where(r => r.Type == "critics_score").FirstOrDefault(); var e = rt.Links.Where(r => r.Type == "alternate").FirstOrDefault(); if (a != null) rtMovie.AudienceRating = a.Score; else rtMovie.AudienceRating = "Unknown"; if (b != null) rtMovie.AudienceScore = b.Score; if (c != null) rtMovie.CriticsRating = c.Score; else rtMovie.CriticsRating = "Unknown"; if (d != null) rtMovie.CriticsScore = d.Score; if (e != null) rtMovie.WebsiteLink = e.Url; if (rtMovie.CriticsRating != null) rtMovie.CriticsRating = rtMovie.CriticsRating.Replace("\"", "").ToLower(); if (rtMovie.AudienceRating != null) rtMovie.AudienceRating = rtMovie.AudienceRating.Replace("\"", "").ToLower(); if (rtMovie.CriticsScore == "-1") { rtMovie.CriticsScore = rtMovie.AudienceScore; rtMovie.CriticsRating = "popcorn"; } db.RtMovies.InsertOnSubmit(rtMovie); } else { rtMovie = new RtMovy(); rtMovie.WebsiteLink = string.Empty; rtMovie.AudienceRating = ""; rtMovie.AudienceScore = "0"; rtMovie.CriticsScore = "0"; rtMovie.CriticsRating = ""; rtMovie.MovieID = m.Netflix.MovieID; db.RtMovies.InsertOnSubmit(rtMovie); } } } else { rtMovie = new RtMovy(); rtMovie.WebsiteLink = string.Empty; rtMovie.AudienceRating = ""; rtMovie.AudienceScore = "0"; rtMovie.CriticsScore = "0"; rtMovie.CriticsRating = ""; } movieData.Add( new MovieModel( m.Netflix, rtMovie)); // movieData.Add(new MovieModel(m.NetflixID, m.Title, m.ReleaseYear, m.Rating, m.Synopsis, m.ShortSynopsis, m.AverageRating, m.LargeUrl, m.Runtime, rtMovie.AudienceScore, rtMovie.WebsiteLink, rtMovie.CriticsScore, rtMovie.AudienceRating, rtMovie.CriticsRating, m.ExpiresDate, m.ApiId.Value)); } db.SubmitChanges(); return movieData; }
public MovieModel(NetflixMovy netflix, RtMovy rottenTomato) { _netflix = netflix; _rottenTomato = rottenTomato; }