コード例 #1
0
        public ActionResult EditPerson(Person p)
        {
            if (ModelState.IsValid)
            {
                if (dbm.updatePerson(p))
                {
                    string output = p.fullName() + " has been updated";
                    TempData["Success"] = output;
                }
                else 
                {
                    string output = p.fullName() + " could not be updated";
                    TempData["Failure"] = output;  
                }

                return RedirectToAction("People");
            }

            return View(p);
        }
コード例 #2
0
        public ActionResult CreatePerson(Person p)
        {

            if (ModelState.IsValid)
            {
               if(dbm.addWorker(p))
               {
                   String output = p.fullName() + " has been added to database";
                   TempData["Success"] = output;
               }
               else 
               {
                   String output = "person id has to be unique";
                   TempData["Failure"] = output;
               }

                return RedirectToAction("People");
            }
            return View();
        }