public ActionResult Create(Country country)
 {
     if (ModelState.IsValid) {
         countryRepository.InsertOrUpdate(country);
         countryRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
Esempio n. 2
0
 public void InsertOrUpdate(Country country)
 {
     if (country.ISO == default(string)) {
         // New entity
         context.Country.Add(country);
     } else {
         // Existing entity
         context.Country.Attach(country);
         context.Entry(country).State = EntityState.Modified;
     }
 }