Пример #1
0
 public ActionResult Create(Region region)
 {
     if (ModelState.IsValid) {
         regionRepository.InsertOrUpdate(region);
         regionRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
Пример #2
0
 public void InsertOrUpdate(Region region)
 {
     if (region.ID == default(int)) {
         // New entity
         context.Region.Add(region);
     } else {
         // Existing entity
         context.Region.Attach(region);
         context.Entry(region).State = EntityState.Modified;
     }
 }