Example #1
0
        public ActionResult Create(Person p)
        {
            if (!ModelState.IsValid)
            {
                return View("Create", p);
            }

            people.Add(p);

            return RedirectToAction("Index");
        }
Example #2
0
        public ActionResult Delete(Person p)
        {
            foreach (Person pn in people)
            {
                if (pn.Id == p.Id)
                {
                    people.Remove(pn);
                    break;
                }
            }

            return RedirectToAction("Index");
        }
Example #3
0
        //
        // 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);
        }
Example #4
0
        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");
        }
Example #5
0
 //
 // GET: /Person/Details/5
 public ActionResult Details(Person p)
 {
     return View(p);
 }