public void MapPersonDto_GivenNullPerson_ShouldReturnNull()
 {
     //---------------Set up test pack-------------------
     var mapper = new PersonMapper();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var personDto = mapper.MapPersonDto(null);
     //---------------Test Result -----------------------
     Assert.IsNull(personDto);
 }
 public void MapPersonDto_GivenPerson_ShouldReturnPersonDto()
 {
     //---------------Set up test pack-------------------
     var person = CreateValidPerson();
     var mapper = new PersonMapper();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     PersonDto personDto = mapper.MapPersonDto(person);
     //---------------Test Result -----------------------
     Assert.AreEqual(person.Id, personDto.Id);
 }
Пример #3
0
 public ActionResult Create(PersonViewModel person)
 {
     if (ModelState.IsValid)
     {
         var personRepo = _personRepo;
         var mapper = new PersonMapper();
         var dto = mapper.MapPersonDto(person);
         personRepo.Add(dto);
         return RedirectToAction("Index");
     }
     return View();
 }
Пример #4
0
        public ActionResult Edit(PersonViewModel item)
        {
            try
            {
                var map = new PersonMapper();
                var personDto = map.MapPersonDto(item);
                _personRepo.Update(personDto);

                return RedirectToAction("Index");
            }
            catch (Exception e)
            {
                var x = e;
                return View();
            }

        }