protected IEnumerable<CreateEmergencyContactRequest> MapEmergencyContactDetails(EmployeeViewModel viewModel)
        {
            var result = new List<CreateEmergencyContactRequest>();

            foreach (var request in viewModel.EmergencyContactDetails)
            {
                var addEmergencyContactRequest = new CreateEmergencyContactRequest()
                                                     {
                                                         Title = request.Title, 
                                                         Forename = request.Forename, 
                                                         Surname = request.Surname, 
                                                         Relationship = request.Relationship, 
                                                         WorkTelephone = request.WorkTelephone, 
                                                         HomeTelephone = request.HomeTelephone, 
                                                         PreferredContactNumber = request.PreferredContactNumber, 
                                                         MobileTelephone = request.MobileTelephone,
                                                         SameAddressAsEmployee = request.SameAddressAsEmployee,
                                                         Address1 = request.Address1,
                                                         Address2 = request.Address2,
                                                         Address3 = request.Address3,
                                                         Town = request.Town,
                                                         County = request.County,
                                                         CountryId = request.EmergencyContactCountryId.GetValueOrDefault(),
                                                         PostCode = request.PostCode
                                                     };

                result.Add(addEmergencyContactRequest);
            }

            return result;
        }
        public void CreateEmergencyContactDetailForEmployee(CreateEmergencyContactRequest request)
        {
            _log.Add(request);
            try
            {

                var employee = _employeeRepository.GetByIdAndCompanyId(request.EmployeeId, request.CompanyId);
                var user = _userForAuditingRepository.GetByIdAndCompanyId(request.UserId, request.CompanyId);

                var emergencyContactDetailsParameter = _emergencyContactDetailsParametersMapper.Map(request, employee);
                var emergencyContactDetail = EmployeeEmergencyContactDetail.Create(emergencyContactDetailsParameter, user);

                employee.AddEmergencyContact(emergencyContactDetail, user);

                _employeeRepository.SaveOrUpdate(employee);

            }
            catch (Exception ex)
            {
                _log.Add(ex);
                throw;
            }
        }