public ActionResult Edit(int id) { var service = CreatePodcastService(); var detail = service.GetPodcastByID(id); var model = new PodcastEdit { PodcastID = detail.PodcastID, Title = detail.Title, PodcastEpisodeTitle = detail.PodcastEpisodeTitle, Description = detail.Description, WebsiteUrl = detail.WebsiteUrl }; return(View(model)); }
public bool UpdatePodcast(PodcastEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Podcasts .Single(e => e.PodcastID == model.PodcastID); /*&& e.UserId == _userID);*/ entity.Title = model.Title; entity.PodcastEpisodeTitle = model.PodcastEpisodeTitle; entity.Description = model.Description; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, PodcastEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.PodcastID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreatePodcastService(); if (service.UpdatePodcast(model)) { TempData["SaveResult"] = "Your podcast was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your podcast could not be updated."); return(View(model)); }