Exemplo n.º 1
0
 public void CopyFrom(Person person)
 {
     Anrede = person.Anrede;
     Nachname = person.Nachname;
     Vorname = person.Vorname;
     Geburtsjahr = person.Geburtsjahr;
 }
 public ActionResult Create(Person person)
 {
     if (ModelState.IsValid) {
         using (var dbContext = new BadHomburgDbContext()) {
             dbContext.Personen.Add(person);
             dbContext.SaveChanges();
             return RedirectToAction("Details", new {person.Id});
         }
     }
     return View(person);
 }
 public ActionResult Edit(int id, Person person)
 {
     if (ModelState.IsValid)
     {
         using (var dbContext = new BadHomburgDbContext()) {
             var oldPerson = dbContext.Personen.Single(p => p.Id == id);
             oldPerson.CopyFrom(person);
             dbContext.SaveChanges();
             return RedirectToAction("Details", new { id });
         }
     }
     return View(person);
 }
 public ActionResult Create()
 {
     var person = new Person();
     return View(person);
 }