public ActionResult Create(Person p) { if (!ModelState.IsValid) { return View("Create", p); } people.Add(p); return RedirectToAction("Index"); }
public ActionResult Delete(Person p) { foreach (Person pn in people) { if (pn.Id == p.Id) { people.Remove(pn); break; } } return RedirectToAction("Index"); }
// // GET: /Person/Delete/5 public ActionResult Delete(int id) { Person p = new Person(); foreach (Person pn in people) { if (pn.Id == id) { p.Name = pn.Name; p.Age = pn.Age; p.Id = pn.Id; p.Phone = pn.Phone; p.Email = pn.Email; } } return View(p); }
public ActionResult Edit(Person p) { if (!ModelState.IsValid) { return View("Edit", p); } foreach (Person pn in people) { if (pn.Id == p.Id) { pn.Name = p.Name; pn.Age = p.Age; pn.Id = p.Id; pn.Phone = p.Phone; pn.Email = p.Email; } } return RedirectToAction("Index"); }
// // GET: /Person/Details/5 public ActionResult Details(Person p) { return View(p); }