// // GET: /Speaker/Create public ActionResult Add(string id) { var conference = YouConfDbContext.Conferences .FirstOrDefault(x => x.HashTag == id); var speaker = new Speaker() { ConferenceId = conference.Id }; ModelState.Remove("id"); ViewBag.ConferenceHashTag = id; return View(speaker); }
public ActionResult Add(string conferenceHashTag, Speaker speaker) { if (ModelState.IsValid) { YouConfDbContext.Speakers.Add(speaker); YouConfDbContext.SaveChanges(); UpdateConferenceInSolrIndex(speaker.ConferenceId, Common.Messaging.SolrIndexAction.Update); return RedirectToAction("Details", "Conference", new { hashTag = conferenceHashTag }); } ViewBag.ConferenceId = conferenceHashTag; return View(speaker); }
public ActionResult Edit(Speaker speaker) { if (ModelState.IsValid) { var currentSpeaker = YouConfDbContext.Speakers .FirstOrDefault(x => x.Id == speaker.Id); if (currentSpeaker == null) { return HttpNotFound(); } Mapper.Map(speaker, currentSpeaker); YouConfDbContext.SaveChanges(); UpdateConferenceInSolrIndex(currentSpeaker.ConferenceId, Common.Messaging.SolrIndexAction.Update); return RedirectToAction("Details", "Conference", new { hashTag = currentSpeaker.Conference.HashTag }); } ViewBag.ConferenceId = speaker.ConferenceId; return View(speaker); }