public ActionResult Create(Region region) { try { if (!ModelState.IsValid) throw new Exception(); this.UnitOfWork.RegionRepository.Insert(region); this.UnitOfWork.Save(); return RedirectToAction("Index", "Region"); } catch { return View(region); } }
public ActionResult Edit(Region region) { try { if (!ModelState.IsValid) return View(region); var originalRegion = this.UnitOfWork.RegionRepository.GetByID(region.Id); if (originalRegion == null) throw new Exception(); originalRegion.Name = region.Name; this.UnitOfWork.RegionRepository.Update(originalRegion); this.UnitOfWork.Save(); return RedirectToAction("Index", "Region"); } catch { return View(region); } }
// CREATE ROLE public ActionResult Create() { var model = new Region(); return View(model); }