예제 #1
0
 public void InsertOrUpdate(Country country)
 {
     if (country.ID == default(int)) {
         // New entity
         context.Countries.Add(country);
     } else {
         // Existing entity
         context.Entry(country).State = EntityState.Modified;
     }
 }
예제 #2
0
 public ActionResult Create(Country country)
 {
     if (ModelState.IsValid) {
         countryRepository.InsertOrUpdate(country);
         countryRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }