public ActionResult Create(Region region) { if (ModelState.IsValid) { db.Regions.Add(region); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.RegionTypeId = new SelectList(db.RegionTypes, "RegionTypeId", "RegionTypeName", region.RegionTypeId); ViewBag.ParentRegionId = new SelectList(db.Regions, "RegionId", "RegionName", region.ParentRegionId); return View(region); }
public ActionResult Edit(Region region) { if (ModelState.IsValid) { db.Entry(region).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.RegionTypeId = new SelectList(db.RegionTypes, "RegionTypeId", "RegionTypeName", region.RegionTypeId); ViewBag.ParentRegionId = new SelectList(db.Regions, "RegionId", "RegionName", region.ParentRegionId); return View(region); }