public void EditInsuree(AddOrEditInsuree editInsuree)
 {
     try
     {
         using (_unitOfWorkFactory.Create())
         {
             var insureeToUpdate = _insureeRepository.FindById(editInsuree.Id);
             _mapper.Map(editInsuree, insureeToUpdate, typeof(AddOrEditInsuree), typeof(Insuree));
             _logger.Info($"Updated insuree with id: {editInsuree.Id}");
         }
     }
     catch (ModelValidationException e)
     {
         _logger.Error("Could not update insuree.", e);
     }
 }
 public void AddInsuree(AddOrEditInsuree addInsuree)
 {
     try
     {
         using (_unitOfWorkFactory.Create())
         {
             var insuree = new Insuree();
             _mapper.Map(addInsuree, insuree);
             _insureeRepository.Add(insuree);
             _logger.Info("Created new insuree.");
         }
     }
     catch (ModelValidationException e)
     {
         _logger.Error("Could not create insuree.", e);
     }
 }
Exemplo n.º 3
0
        public void MappingInsureeToAddOrEditInsureeIsValid()
        {
            var insuree = CreateInsuree();
            var createOrEditInsuree = new AddOrEditInsuree();

            Mapper.Map(insuree, createOrEditInsuree);

            createOrEditInsuree.Id.ShouldBeEquivalentTo(insuree.Id);
            createOrEditInsuree.FirstName.ShouldBeEquivalentTo(insuree.FirstName);
            createOrEditInsuree.LastName.ShouldBeEquivalentTo(insuree.LastName);
            createOrEditInsuree.DateOfBirth.ShouldBeEquivalentTo(insuree.DateOfBirth);
        }
        public AddOrEditInsuree GetExistingInsureeToEdit(int id)
        {
            var insuree = _insureeRepository.FindById(id);
            var createOrEditInsuree = new AddOrEditInsuree();

            _mapper.Map(insuree, createOrEditInsuree);

            return createOrEditInsuree;
        }
        public AddOrEditInsuree GetNewInsuree()
        {
            var createOrEditInsuree = new AddOrEditInsuree();

            return createOrEditInsuree;
        }