Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
 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();
     }
 }