public ActionResult Delete(int id, Person p) { try { List<Person> oldList = (List<Person>)Session["Classmates"]; oldList.RemoveAll(x => x.Id == id); Session["Classmates"] = oldList; PersonList = oldList; return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit(int id, Person p) { try { var tmp = (List<Person>)Session["Classmates"]; var tmp2 = tmp.First(pe => pe.Id == id); tmp2.Name = p.Name; tmp2.YearsOld = p.YearsOld; Session["Classmates"] = tmp; return RedirectToAction("Index"); } catch { return View(); } }