public ActionResult Create(PersonViewModel personViewModel)
 {
     if (!ModelState.IsValid) return View(personViewModel);
     var person = _mappingEngine.Map<PersonViewModel, Person>(personViewModel);
     _personRepository.Save(person);
     return RedirectToAction("Index");
 }
        public ActionResult Edit(PersonViewModel personViewModel)
        {
            if (ModelState.IsValid)
            {
                var existingPerson = _personRepository.GetById(personViewModel.Id);
                var newPerson = _mappingEngine.Map<PersonViewModel, Person>(personViewModel);
                _personRepository.Update(existingPerson, newPerson);

                return RedirectToAction("Index");
            }
            return View(personViewModel);
        }
 public void Edit_POST_ShouldReturnViewWithPersonViewModel()
 {
     //---------------Set up test pack-------------------
     var personViewModel = new PersonViewModel();
     var personController = CreatePersonController().Build();
     personController.ModelState.AddModelError("key", "some error");
     //---------------Assert Precondition----------------
     Assert.IsFalse(personController.ModelState.IsValid);
     //---------------Execute Test ----------------------
     var result = personController.Edit(personViewModel);
     //---------------Test Result -----------------------
     Assert.IsNotNull(result);
 }