public IActionResult Edit(TvListingSource tvListingSource) { if (ModelState.IsValid) { _context.Update(tvListingSource); _context.SaveChanges(); return RedirectToAction("Index"); } return View(tvListingSource); }
/// <summary> /// Locates a Source by URI or creates a new one if it doesn't exist /// </summary> /// <param name="uri"></param> /// <param name="sourceName"></param> /// <returns></returns> public TvListingSource GetSourceByUri(string uri, string sourceName) { var local = ChangeTracker.Entries<TvListingSource>().SingleOrDefault(x => x.Property(y => y.SourceUri).CurrentValue == uri); if (local != null) return local.Entity; var remote = Sources.SingleOrDefault(x => x.SourceUri == uri); if (remote != null) return remote; // if they didn't specify the name we can't create it so they get an exception instead if (!string.IsNullOrWhiteSpace(sourceName)) throw new SourceNotFoundException(string.Format("Source URI {0} not found", uri)); // create store and return the source var newsource = new TvListingSource { DisplayName = sourceName.Trim(), SourceUri = uri }; Sources.Add(newsource); return newsource; }
public TvProgramBroadCastListingImport CreateImportTag(TvListingSource source) { var import = new TvProgramBroadCastListingImport { ListingSource = source, Start = DateTime.UtcNow, Running = true }; Imports.Add(import); SaveChanges(); return import; }