public ActionResult Create(PodcastCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreatePodcastService(); if (service.CreatePodcast(model)) { TempData["SaveResult"] = "Your podcast was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Podcast could not be created."); return(View(model)); }
public bool CreatePodcast(PodcastCreate model) { var entity = new Podcast() { UserId = _userID, CrimeID = model.CrimeID, Crime = model.Crime, Title = model.Title, PodcastEpisodeTitle = model.PodcastEpisodeTitle, Description = model.Description, WebsiteUrl = model.WebsiteUrl, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Podcasts.Add(entity); return(ctx.SaveChanges() == 1); } }