Example #1
0
 public ActionResult Create(Person person)
 {
     if (ModelState.IsValid)
     {
         _repository.Add(person);
         Success("Your information was saved!");
         return RedirectToAction("Index");
     }
     Error("there were some errors in your form.");
     return View(person);
 }
Example #2
0
        public ActionResult Edit(Person person)
        {
            if (ModelState.IsValid)
            {
                _repository.Update(person);
                Success("Your record was updated.");
                return RedirectToAction("Index");
            }

            Error("There was a problem saving your record");
            return View(person);
        }
Example #3
0
 public void Update(Person person)
 {
     var oldPerson = Get(person.Id);
     _context.Entry(oldPerson).CurrentValues.SetValues(person);
     _context.SaveChanges();
 }
Example #4
0
 public ActionResult Create()
 {
     var person = new Person();
     return View(person);
 }
Example #5
0
 public void Add(Person newPerson)
 {
     _context.People.Add(newPerson);
     _context.SaveChanges();
 }