public ActionResult Create(Speaker model) { try { var repository = new ObjectRepository<Speaker>(); if (0 < (repository.Find(s => s.Name == model.Name)).Count()) { throw new WebException("The speaker already exists."); } model.Id = Guid.NewGuid(); repository.Save(model); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Create(Speaker model) { try { var q = (from Speaker o in Db where o.Id == model.Id select o); if (0 < q.Count()) { throw new WebException("The speaker already exists."); } model.Id = Guid.NewGuid(); Db.Store(model); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(Guid id, Speaker speaker) { try { var model = (from Speaker o in Db where o.Id == id select o).First(); model.Name = speaker.Name; model.ImageName = speaker.ImageName; model.Biography = speaker.Biography; Db.Store(model); return RedirectToAction("Details", new {speaker.Id}); } catch { return View(); } }
public ActionResult Edit(Guid id, Speaker speaker) { try { var repository = new ObjectRepository<Speaker>(); repository.Save(speaker); return RedirectToAction("Index"); } catch { return View(); } }