public EmergencyContactDetailParameters Map(SaveEmergencyContactBaseRequest request, Employee employee)
        {
            var result = new EmergencyContactDetailParameters
                {
                    EmergencyContactId =  request.EmergencyContactId,
                    Title = request.Title,
                    Forename = request.Forename,
                    Surname = request.Surname,
                    Relationship = request.Relationship,
                    SameAddressAsEmployee = request.SameAddressAsEmployee,
                    Telephone1 = request.WorkTelephone,
                    Telephone2 = request.HomeTelephone,
                    Telephone3 = request.MobileTelephone,
                    PreferedTelephone = request.PreferredContactNumber,
                    Address1 = request.Address1,
                    Address2 = request.Address2,
                    Address3 = request.Address3,
                    Town = request.Town,
                    County = request.County,
                    PostCode = !string.IsNullOrEmpty(request.PostCode) ? request.PostCode.ToUpper(): string.Empty,
                    Country = request.CountryId != 0 ? _countriesRepository.GetById(request.CountryId): null
                };

            return result;
        }
        public IEnumerable<EmergencyContactDetailParameters> Map(SaveEmployeeRequest request)
        {
            var result = new List<EmergencyContactDetailParameters>();
            foreach (var emergencyContactRequest in request.EmergencyContactDetails)
            {
                var emergencyContactDetailParameters = new EmergencyContactDetailParameters
                                                           {

                                                               Title = emergencyContactRequest.Title,
                                                               Forename = emergencyContactRequest.Forename,
                                                               Surname = emergencyContactRequest.Surname,
                                                               Relationship = emergencyContactRequest.Relationship,
                                                               Telephone1 = emergencyContactRequest.WorkTelephone,
                                                               Telephone2 = emergencyContactRequest.HomeTelephone,
                                                               Telephone3 = emergencyContactRequest.MobileTelephone,
                                                               PreferedTelephone = emergencyContactRequest.PreferredContactNumber,
                                                               Address1 = emergencyContactRequest.Address1,
                                                               Address2 = emergencyContactRequest.Address2,
                                                               Address3 = emergencyContactRequest.Address3,
                                                               County = emergencyContactRequest.County,
                                                               PostCode = emergencyContactRequest.PostCode
                                                           };

                if (emergencyContactRequest.CountryId != 0)
                {
                    emergencyContactDetailParameters.Country = _countriesRepository.GetById(emergencyContactRequest.CountryId);
                }

                result.Add(emergencyContactDetailParameters);
            }
            return result;
        }
Esempio n. 3
0
        public void Given_has_contact_detail_found_When_UpdateEmergencyContact_Then_calls_correct_method()
        {
            // Given
            var emergencyContactDetailParameters = new EmergencyContactDetailParameters
            {
                EmergencyContactId = 1L
            };

            var userForAuditing = new UserForAuditing();
            var target = new Employee();

            var employeeEmergencyContactDetail = new Mock<EmployeeEmergencyContactDetail>();
            employeeEmergencyContactDetail
                .Setup(x => x.Id)
                .Returns(1);

            employeeEmergencyContactDetail
                .Setup(x => x.Update(emergencyContactDetailParameters, userForAuditing));

            target.EmergencyContactDetails.Add(employeeEmergencyContactDetail.Object);

            // When
            target.UpdateEmergencyContact(emergencyContactDetailParameters, userForAuditing);

            // Then
            employeeEmergencyContactDetail.Verify(x => x.Update(emergencyContactDetailParameters, userForAuditing));
        }
Esempio n. 4
0
        public void Given_no_contact_detail_found_When_UpdateEmergencyContact_Then_throws_exception()
        {
            // Given
            var contactDetailsParameters = new EmergencyContactDetailParameters()
            {
                EmergencyContactId = 1L
            };

            var userForAuditing = new UserForAuditing();

            var target = new Employee
            {
                EmergencyContactDetails = new List<EmployeeEmergencyContactDetail>
                                                    {
                                                        new EmployeeEmergencyContactDetail
                                                            {
                                                                Id=888
                                                            }
                                                    }
            };

            // When

            // Then
            Assert.Throws<AttemptingToUpdateEmergencyContactEmergencyContactsDetailsNotFoundForEmployeeException>(() => target.UpdateEmergencyContact(contactDetailsParameters, userForAuditing));
        }