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(); } }
/// <summary> /// Edits the specified id. /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public ActionResult Edit(Guid id) { var repository = new ObjectRepository<Speaker>(); var model = repository.Find(s => s.Id == id); return View(model); }
/// <summary> /// Detailses the specified id. /// </summary> /// <param name="id">The id.</param> /// <returns></returns> public ActionResult Details(Guid id) { var repository = new ObjectRepository<Speaker>(); var model = repository.Find(m => m.Id == id).First(); return View(model); }