public void Add(TVShow show) { if (!_context.Shows .Any(b => b.SeriesId == show.SeriesId)) { _context.Shows.Add(show); _context.SaveChanges(); } }
public ActionResult Create([Bind(Include = "EpisodeId,Title,Synopsis,OrigionalAirDate,Duration")] Episode episode) { if (ModelState.IsValid) { db.Episodes.Add(episode); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(episode)); }
public ActionResult Create([Bind(Include = "EpisodeID,Season,Episodes,Title,Date_Aired,Plot,Review,Complete")] Episode episode) { if (ModelState.IsValid) { db.Episodes.Add(episode); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(episode)); }
public void UpdateEpisodeIfLastUpdatedIsNewer(Episode ep) { Episode epFromDB = _context.Episodes .FirstOrDefault(b => b.TVDBEpisodeId == ep.TVDBEpisodeId); if (epFromDB != null // comment out next 2 lines if LastUpdated bug on thetvdb API is still around && (epFromDB.LastUpdated < ep.LastUpdated) ) { Log.Information("LastUpdated property newer on Episode {a}: {b} ", epFromDB.Id, ep.EpisodeName); ep.Id = epFromDB.Id; _context.Entry(epFromDB).CurrentValues.SetValues(ep); _context.SaveChanges(); Log.Information("Updated entry for {a}: {b}", epFromDB.Id, ep.EpisodeName); } }
static void AddSampleShow(EpisodeContext context) { TVShow theOrville = new TVShow() { SeriesId = 328487, SeriesName = "The Orville", SeriesNamePreferred = null, }; context.Add(theOrville); context.SaveChanges(); }