/// <summary> /// Create a new shows object. /// </summary> /// <param name="id">Initial value of the id property.</param> public static shows Createshows(global::System.Int64 id) { shows shows = new shows(); shows.id = id; return shows; }
/// <summary> /// Deprecated Method for adding a new object to the shows EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToshows(shows shows) { base.AddObject("shows", shows); }
private void AddNewShowWithEpisodes(string showName) { //TODO: Find a way to migrate aliases to Database... or not, not a big deal IMO //Update the shows table, get TVDB ID and Name, possible get TVRage ID and Name Logger.Log("Checking if {0} is in Database: ", showName); try { using (SABSyncEntities sabSyncEntities = new SABSyncEntities()) { if (sabSyncEntities.shows.Any(s => s.show_name == showName)) //If show was already added...skip it (Use local disk name) return; //Get TVDB ID & Name TvDbShowInfo info = new TvDbShowInfo(); info = TvDb.GetShowData(showName); if (info == null) return; //string aliases = GetAliasForDb(showName, info.SeriesName); int downloadQuality = GetQualityForDb(); //Add to shows Database shows newItem = new shows { id = new int(), show_name = showName, tvdb_id = Convert.ToInt32(info.SeriesId), tvdb_name = info.SeriesName, ignore_season = 0, air_day = info.AirDay, air_time = info.AirTime, run_time = Convert.ToInt32(info.RunTime), status = info.Status, poster_url = info.PosterUrl, banner_url = info.BannerUrl, imdb_id = info.ImdbId, genre = info.Genre.Trim('|'), overview = info.Overview, quality = downloadQuality, aliases = GetAliasForDb(showName) }; Logger.Log("Adding {0} to database.", showName); sabSyncEntities.AddToshows(newItem); sabSyncEntities.SaveChanges(); //Save show to Database after each show var newShow = (from s in sabSyncEntities.shows where s.tvdb_id == info.SeriesId select s).FirstOrDefault(); //Get the PK for the show just added (so we can get the banner) TvDb.GetBanner(info.BannerUrl, newShow.id); //Get the banner and save to disk AddEpisodes(info.Episodes, Convert.ToInt32(info.SeriesId)); //Add all episodes for this show } } catch (Exception ex) { Logger.Log(ex.ToString()); } }