public ActionResult Create(Person person)
 {
     if (ModelState.IsValid) {
         personRepository.InsertOrUpdate(person);
         personRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
 public void InsertOrUpdate(Person person)
 {
     if (person.Id == default(int))
     {
         // New entity
         context.People.Add(person);
     }
     else
     {
         // Existing entity
         context.Entry(person).State = EntityState.Modified;
     }
 }