public JsonResult CreateNewPerson(Person person)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.People.Add(person);
             db.SaveChanges();
             return Json(new { success = true, message = "Successfully added person." });
         }
         return Json(new { success = false, message = "Model state is invalid or missing required information." });
     }
     catch(Exception ex)
     {
         return Json(new {
             success = false,
             message = "Failed to add new person! (" + ex + ")"
         });
     }
 }
Exemple #2
0
 public AppModel()
 {
     NewPerson = new Person();
 }