Esempio 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);
        }
Esempio 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);
 }