Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
 }