public ActionResult Create(Persons persons) { if (ModelState.IsValid) { db.Persons.Add(persons); db.SaveChanges(); return RedirectToAction("Index"); } return View(persons); }
public ActionResult Edit( Persons persons) { if (ModelState.IsValid) { db.Entry(persons).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(persons); }
private bool TryFindInDB(string key, out Persons person) { person = null; try { var matchingEntity = from p in db.Persons.ToList() where p.OSEntityPK.ToString() == key || p.PhoneNumber == key select p; person = matchingEntity.Single(); } catch (InvalidOperationException e) { return false; } return true; }