public ActionResult Create(CreatePersonViewModel create_person) { if (ModelState.IsValid) { var name = new Name(create_person.first_name, create_person.last_name); var person_to_add = new Person(name); using (_unit_of_work_factory.create()) { _person_repository.save(person_to_add); } TempData.Add("Message", String.Format("New person added '{0}'", person_to_add.name)); return RedirectToAction("Index", "DisplayAllPeople"); } else return View(create_person); }
public ActionResult Edit(EditPersonViewModel person_that_has_changed) { if (ModelState.IsValid) { var person_to_edit = _person_repository.find_by(person_that_has_changed.id); var original_name = person_to_edit.name; var new_name = new Name(person_that_has_changed.first_name, person_that_has_changed.last_name); person_to_edit.change_name_to(new_name); using (_unit_of_work_factory.create()) { _person_repository.save(person_to_edit); } TempData.Add("Message", String.Format("Name changed from '{0}' to '{1}'", original_name, person_to_edit.name)); return RedirectToAction("Index", "DisplayAllPeople"); } else return View(person_that_has_changed); }
public Person(Name name) { this.name = name; id = Guid.NewGuid(); }
public void change_name_to(Name new_name) { name = new_name; }