public ActionResult Create(Person person) { if (ModelState.IsValid) { _repository.Add(person); Success("Your information was saved!"); return RedirectToAction("Index"); } Error("there were some errors in your form."); return View(person); }
public ActionResult Edit(Person person) { if (ModelState.IsValid) { _repository.Update(person); Success("Your record was updated."); return RedirectToAction("Index"); } Error("There was a problem saving your record"); return View(person); }
public void Update(Person person) { var oldPerson = Get(person.Id); _context.Entry(oldPerson).CurrentValues.SetValues(person); _context.SaveChanges(); }
public ActionResult Create() { var person = new Person(); return View(person); }
public void Add(Person newPerson) { _context.People.Add(newPerson); _context.SaveChanges(); }