Beispiel #1
0
        public PrincipalAuthorityProfile()
        {
            CreateMap <PrincipalAuthority, PrincipalAuthorityViewModel>()
            .ForMember(x => x.Id, opt => opt.MapFrom(y => y.Id))
            .ForMember(x => x.IsDirector, opt => opt.ResolveUsing(DirectorResolver))
            .ForMember(x => x.DirectorOrPartnerId, opt => opt.MapFrom(y => y.DirectorOrPartnerId))
            .ForMember(x => x.PrincipalAuthorityConfirmation, opt => opt.ResolveUsing(ConfirmationResolver))
            .ForMember(x => x.BirthDetailsViewModel, opt => opt.ResolveUsing(ProfileHelpers.BirthDetailsResolver <PrincipalAuthorityViewModel>))
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.FullName, opt => opt.ResolveUsing(ProfileHelpers.FullNameResolver))
            .ForMember(x => x.AlternativeName, opt => opt.ResolveUsing(ProfileHelpers.AlternativeFullNameResolver))
            .ForMember(x => x.JobTitle, opt => opt.ResolveUsing(ProfileHelpers.JobTitleResolver))
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.ResolveUsing(ProfileHelpers.BusinessPhoneNumberResolver))
            .ForMember(x => x.BusinessExtension, opt => opt.ResolveUsing(ProfileHelpers.BusinessExtensionResolver))
            .ForMember(x => x.PersonalMobileNumber, opt => opt.ResolveUsing(ProfileHelpers.PersonalMobileNumberResolver))
            .ForMember(x => x.PersonalEmailAddress, opt => opt.ResolveUsing(ProfileHelpers.PersonalEmailAddressResolver))
            .ForMember(x => x.Nationality, opt => opt.ResolveUsing(ProfileHelpers.NationalityResolver))
            .ForMember(x => x.LegalStatus, opt => opt.MapFrom(y => y.Licence.LegalStatus))
            .ForMember(x => x.PassportViewModel, opt => opt.ResolveUsing(ProfileHelpers.PassportViewModel))
            .ForMember(x => x.PrincipalAuthorityRightToWorkViewModel, opt => opt.ResolveUsing(PrincipalAuthorityRightToWorkResolver))
            .ForMember(x => x.UndischargedBankruptViewModel, opt => opt.ResolveUsing(ProfileHelpers.UndischargedBankruptResolver))
            .ForMember(x => x.DisqualifiedDirectorViewModel, opt => opt.ResolveUsing(ProfileHelpers.DisqualifiedDirectorResolver))
            .ForMember(x => x.RestraintOrdersViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.UnspentConvictionsViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.OffencesAwaitingTrialViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.PreviousLicenceViewModel, opt => opt.ResolveUsing(ProfileHelpers.PreviousLicenceResolver))
            .ForMember(x => x.PreviousExperience, opt => opt.ResolveUsing(PreviousExperienceResolver))
            .ForMember(x => x.IsUk, opt => opt.MapFrom(y => y.CountryOfBirth != null && y.CountryOfBirth.IsUk))
            .ForMember(x => x.Counties, opt => opt.Ignore())
            .ForMember(x => x.Countries, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.ResolveUsing(x => ProfileHelpers.GetIsSubmitted(x.Licence)))
            .ForMember(x => x.Address, opt => opt.Condition(y => y.Address != null));

            CreateMap <PrincipalAuthority, IsDirectorViewModel>()
            .ForMember(x => x.IsDirector, opt => opt.MapFrom(y => y.IsDirector))
            .ForMember(x => x.YesNo, opt => opt.Ignore());

            CreateMap <PrincipalAuthority, PrincipalAuthorityConfirmationViewModel>()
            .ConvertUsing(ConfirmationResolver);

            CreateMap <PrincipalAuthority, BirthDetailsViewModel>()
            .ConvertUsing(ProfileHelpers.BirthDetailsResolver);

            CreateMap <PrincipalAuthority, AlternativeFullNameViewModel>()
            .ConvertUsing(ProfileHelpers.AlternativeFullNameResolver);

            CreateMap <AlternativeFullNameViewModel, PrincipalAuthority>()
            .ForMember(x => x.AlternativeName, opt => opt.MapFrom(y => y.AlternativeName))
            .ForMember(x => x.HasAlternativeName, opt => opt.MapFrom(y => y.HasAlternativeName))
            .ForAllOtherMembers(opt => opt.Ignore());

            // TODO: make IsCurrent work properly
            CreateMap <IsPreviousPrincipalAuthorityViewModel, PrincipalAuthority>()
            .ForMember(x => x.IsDirector, opt => opt.MapFrom(y => y.IsPreviousPrincipalAuthority))
            .ForMember(x => x.IsCurrent, opt => opt.UseValue(true))
            .ForAllOtherMembers(opt => opt.Ignore());

            // TODO: make IsCurrent work properly
            CreateMap <IsDirectorViewModel, PrincipalAuthority>()
            .ForMember(x => x.IsDirector, opt => opt.MapFrom(y => y.IsDirector))
            .ForMember(x => x.IsCurrent, opt => opt.UseValue(true))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthorityConfirmationViewModel, PrincipalAuthority>()
            .ForMember(x => x.WillProvideConfirmation, opt => opt.MapFrom(y => y.WillProvideConfirmation))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PreviousExperienceViewModel, PrincipalAuthority>()
            .ForMember(x => x.PreviousExperience, opt => opt.MapFrom(y => y.PreviousExperience))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <FullNameViewModel, PrincipalAuthority>()
            .ForMember(x => x.FullName, opt => opt.MapFrom(y => y.FullName))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <DateOfBirthViewModel, PrincipalAuthority>()
            .ForMember(x => x.DateOfBirth, opt => opt.MapFrom(y => y.DateOfBirth.Date))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BirthDetailsViewModel, PrincipalAuthority>()
            .ForMember(x => x.TownOfBirth, opt => opt.MapFrom(y => y.TownOfBirthViewModel.TownOfBirth))
            .ForMember(x => x.CountryOfBirthId, opt => opt.MapFrom(y => y.CountryOfBirthViewModel.CountryOfBirthId))
            .ForMember(x => x.NationalInsuranceNumber, opt => opt.MapFrom(y => y.NationalInsuranceNumberViewModel.NationalInsuranceNumber))
            .ForMember(x => x.SocialSecurityNumber, opt => opt.MapFrom(y => y.SocialSecurityNumberViewModel.SocialSecurityNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <JobTitleViewModel, PrincipalAuthority>()
            .ForMember(x => x.JobTitle, opt => opt.MapFrom(y => y.JobTitle))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BusinessPhoneNumberViewModel, PrincipalAuthority>()
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.MapFrom(y => y.BusinessPhoneNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PersonalMobileNumberViewModel, PrincipalAuthority>()
            .ForMember(x => x.PersonalMobileNumber, opt => opt.MapFrom(y => y.PersonalMobileNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PersonalEmailAddressViewModel, PrincipalAuthority>()
            .ForMember(x => x.PersonalEmailAddress, opt => opt.MapFrom(y => y.PersonalEmailAddress))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BusinessExtensionViewModel, PrincipalAuthority>()
            .ForMember(x => x.BusinessExtension, opt => opt.MapFrom(y => y.BusinessExtension))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NationalityViewModel, PrincipalAuthority>()
            .ForMember(x => x.Nationality, opt => opt.MapFrom(y => y.Nationality))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, NationalityViewModel>()
            .ForMember(x => x.Nationality, opt => opt.MapFrom(y => y.Nationality))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PassportViewModel, PrincipalAuthority>()
            .ForMember(x => x.HasPassport, opt => opt.MapFrom(y => y.HasPassport))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, PassportViewModel>()
            .ForMember(x => x.HasPassport, opt => opt.MapFrom(y => y.HasPassport))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthorityRightToWorkViewModel, PrincipalAuthority>()
            .ForMember(x => x.PermissionToWorkStatus, opt => opt.MapFrom(y => y.RightToWorkInUk))
            .ForMember(x => x.VisaNumber, opt => opt.MapFrom(y => y.VisaNumber))
            .ForMember(x => x.ImmigrationStatus, opt => opt.MapFrom(y => y.ImmigrationStatus))
            .ForMember(x => x.LeaveToRemainTo, opt => opt.MapFrom(y => y.LeaveToRemainTo.Date))
            .ForMember(x => x.LengthOfUKWorkYears, opt => opt.MapFrom(y => y.LengthOfUKWork.Years))
            .ForMember(x => x.LengthOfUKWorkMonths, opt => opt.MapFrom(y => y.LengthOfUKWork.Months))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, PrincipalAuthorityRightToWorkViewModel>()
            .ForMember(x => x.RightToWorkInUk, opt => opt.MapFrom(y => y.PermissionToWorkStatus))
            .ForMember(x => x.VisaNumber, opt => opt.MapFrom(y => y.VisaNumber))
            .ForMember(x => x.ImmigrationStatus, opt => opt.MapFrom(y => y.ImmigrationStatus))
            .ForMember(x => x.LeaveToRemainTo, opt => opt.MapFrom(y => y.LeaveToRemainTo))
            .ForMember(x => x.LengthOfUKWork, opt => opt.ResolveUsing(LengthOfUKWorkResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <UndischargedBankruptViewModel, PrincipalAuthority>()
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.BankruptcyDate))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.BankruptcyNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, UndischargedBankruptViewModel>()
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.BankruptcyDate))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.BankruptcyNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <DisqualifiedDirectorViewModel, PrincipalAuthority>()
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualificationDetails))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, DisqualifiedDirectorViewModel>()
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualificationDetails))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <RestraintOrdersViewModel, PrincipalAuthority>()
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.ResolveUsing(ProfileHelpers.RestraintOrdersResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, RestraintOrdersViewModel>()
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.MapFrom(y => y.RestraintOrders.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <UnspentConvictionsViewModel, PrincipalAuthority>()
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.ResolveUsing(ProfileHelpers.UnspentConvictionsResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, UnspentConvictionsViewModel>()
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.MapFrom(y => y.UnspentConvictions.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <OffencesAwaitingTrialViewModel, PrincipalAuthority>()
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.ResolveUsing(ProfileHelpers.OffencesAwaitingTrialResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, OffencesAwaitingTrialViewModel>()
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.MapFrom(y => y.OffencesAwaitingTrial.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PreviousLicenceViewModel, PrincipalAuthority>()
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthority, PreviousLicenceViewModel>()
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <RightToWorkViewModel, PrincipalAuthority>()
            .ForAllMembers(opt => opt.Ignore());

            CreateMap <PrincipalAuthorityViewModel, PrincipalAuthority>()
            .ForMember(x => x.IsCurrent, opt => opt.Ignore())
            .ForMember(x => x.Licence, opt => opt.Ignore())
            .ForMember(x => x.LicenceId, opt => opt.Ignore())
            .ForMember(x => x.Id, opt => opt.Ignore())
            .ForMember(x => x.DirectorOrPartner, opt => opt.Ignore())
            .ForMember(x => x.DirectorOrPartnerId, opt => opt.MapFrom(y => y.DirectorOrPartnerId))
            .ForMember(x => x.CountyOfBirth, opt => opt.Ignore())
            .ForMember(x => x.FullName, opt => opt.MapFrom(y => y.FullName.FullName))
            .ForMember(x => x.DateOfBirth, opt => opt.MapFrom(y => y.DateOfBirth.DateOfBirth.Date))
            .ForMember(x => x.HasAlternativeName, opt => opt.MapFrom(y => y.AlternativeName.HasAlternativeName))
            .ForMember(x => x.AlternativeName, opt => opt.MapFrom(y => y.AlternativeName.AlternativeName))
            .ForMember(x => x.TownOfBirth, opt => opt.MapFrom(y => y.BirthDetailsViewModel.TownOfBirthViewModel.TownOfBirth))
            .ForMember(x => x.CountryOfBirthId, opt => opt.MapFrom(y => y.BirthDetailsViewModel.CountryOfBirthViewModel.CountryOfBirthId))
            .ForMember(x => x.CountryOfBirth, opt => opt.Ignore())
            .ForMember(x => x.JobTitle, opt => opt.MapFrom(y => y.JobTitle.JobTitle))
            .ForMember(x => x.Address, opt => opt.MapFrom(y => y.Address))
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.MapFrom(y => y.BusinessPhoneNumber.BusinessPhoneNumber))
            .ForMember(x => x.BusinessExtension, opt => opt.MapFrom(y => y.BusinessExtension.BusinessExtension))
            .ForMember(x => x.PersonalEmailAddress, opt => opt.MapFrom(y => y.PersonalEmailAddress.PersonalEmailAddress))
            .ForMember(x => x.PersonalMobileNumber, opt => opt.MapFrom(y => y.PersonalMobileNumber.PersonalMobileNumber))
            .ForMember(x => x.NationalInsuranceNumber, opt => opt.MapFrom(y => y.BirthDetailsViewModel.NationalInsuranceNumberViewModel.NationalInsuranceNumber))
            .ForMember(x => x.SocialSecurityNumber, opt => opt.MapFrom(y => y.BirthDetailsViewModel.SocialSecurityNumberViewModel.SocialSecurityNumber))
            .ForMember(x => x.IsDirector, opt => opt.MapFrom(y => y.IsDirector.IsDirector))
            .ForMember(x => x.WillProvideConfirmation, opt => opt.MapFrom(y => y.PrincipalAuthorityConfirmation.WillProvideConfirmation))
            .ForMember(x => x.PreviousExperience, opt => opt.MapFrom(y => y.PreviousExperience.PreviousExperience))
            .ForMember(x => x.Nationality, opt => opt.MapFrom(y => y.Nationality.Nationality))
            .ForMember(x => x.HasPassport, opt => opt.MapFrom(y => y.PassportViewModel.HasPassport))
            .ForMember(x => x.PermissionToWorkStatus, opt => opt.MapFrom(y => y.PrincipalAuthorityRightToWorkViewModel.RightToWorkInUk))
            .ForMember(x => x.VisaNumber, opt => opt.MapFrom(y => y.PrincipalAuthorityRightToWorkViewModel.VisaNumber))
            .ForMember(x => x.LengthOfUKWorkYears, opt => opt.MapFrom(y => y.PrincipalAuthorityRightToWorkViewModel.LengthOfUKWork.Years))
            .ForMember(x => x.LengthOfUKWorkMonths, opt => opt.MapFrom(y => y.PrincipalAuthorityRightToWorkViewModel.LengthOfUKWork.Months))
            .ForMember(x => x.ImmigrationStatus, opt => opt.MapFrom(y => y.PrincipalAuthorityRightToWorkViewModel.ImmigrationStatus))
            .ForMember(x => x.LeaveToRemainTo, opt => opt.MapFrom(y => y.PrincipalAuthorityRightToWorkViewModel.LeaveToRemainTo.Date))
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.BankruptcyDate.Date))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.BankruptcyNumber))
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.DisqualifiedDirectorViewModel.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualifiedDirectorViewModel.DisqualificationDetails))
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.RestraintOrdersViewModel.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.Ignore())
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.UnspentConvictionsViewModel.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.Ignore())
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.OffencesAwaitingTrialViewModel.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.Ignore())
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.PreviousLicenceViewModel.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceViewModel.PreviousLicenceDescription))
            .ForMember(x => x.RequiresVisa, opt => opt.Ignore())
            .ForMember(x => x.VisaDescription, opt => opt.Ignore())
            .ForMember(x => x.Deleted, opt => opt.Ignore())
            .ForMember(x => x.DateDeleted, opt => opt.Ignore());
        }
        public NamedIndividualProfile()
        {
            CreateMap <Licence, NamedIndividualCollectionViewModel>()
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.IsShellfish, opt => opt.MapFrom(y => y.IsShellfish))
            .ForMember(x => x.TurnoverBand, opt => opt.MapFrom(y => y.TurnoverBand))
            .ForMember(x => x.NamedIndividuals, opt => opt.MapFrom(y => y.NamedIndividuals.Where(z => !z.Deleted)))
            .ForMember(x => x.NamedJobTitles, opt => opt.MapFrom(y => y.NamedJobTitles.Where(z => !z.Deleted)))
            .ForMember(x => x.NamedIndividualType, opt => opt.MapFrom(y => y.NamedIndividualType))
            .ForMember(x => x.IntroText, opt => opt.Ignore())
            .ForMember(x => x.AvailableIndividualTypes, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.ResolveUsing(ProfileHelpers.GetIsSubmitted));

            CreateMap <NamedIndividual, NamedIndividualViewModel>()
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.FullName, opt => opt.ResolveUsing(ProfileHelpers.FullNameResolver))
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.ResolveUsing(ProfileHelpers.BusinessPhoneNumberResolver))
            .ForMember(x => x.BusinessExtension, opt => opt.ResolveUsing(ProfileHelpers.BusinessExtensionResolver))
            .ForMember(x => x.RightToWorkViewModel, opt => opt.ResolveUsing(ProfileHelpers.RightToWorkResolver))
            .ForMember(x => x.UndischargedBankruptViewModel, opt => opt.ResolveUsing(ProfileHelpers.UndischargedBankruptResolver))
            .ForMember(x => x.DisqualifiedDirectorViewModel, opt => opt.ResolveUsing(ProfileHelpers.DisqualifiedDirectorResolver))
            .ForMember(x => x.RestraintOrdersViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.UnspentConvictionsViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.OffencesAwaitingTrialViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.PreviousLicenceViewModel, opt => opt.ResolveUsing(ProfileHelpers.PreviousLicenceResolver))
            .ForMember(x => x.IsSubmitted, opt => opt.ResolveUsing(x => ProfileHelpers.GetIsSubmitted(x.Licence)));

            CreateMap <NamedIndividualViewModel, NamedIndividual>()
            .ForMember(x => x.Licence, opt => opt.Ignore())
            .ForMember(x => x.LicenceId, opt => opt.Ignore())
            .ForMember(x => x.Id, opt => opt.Ignore())
            .ForMember(x => x.FullName, opt => opt.MapFrom(y => y.FullName.FullName))
            .ForMember(x => x.DateOfBirth, opt => opt.MapFrom(y => y.DateOfBirth.DateOfBirth))
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.MapFrom(y => y.BusinessPhoneNumber.BusinessPhoneNumber))
            .ForMember(x => x.BusinessExtension, opt => opt.MapFrom(y => y.BusinessExtension.BusinessExtension))
            .ForMember(x => x.RequiresVisa, opt => opt.MapFrom(y => y.RightToWorkViewModel.RequiresVisa))
            .ForMember(x => x.VisaDescription, opt => opt.MapFrom(y => y.RightToWorkViewModel.VisaDescription))
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.BankruptcyDate.Date))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.BankruptcyNumber))
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.DisqualifiedDirectorViewModel.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualifiedDirectorViewModel.DisqualificationDetails))
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.RestraintOrdersViewModel.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.Ignore())
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.UnspentConvictionsViewModel.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.Ignore())
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.OffencesAwaitingTrialViewModel.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.Ignore())
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.PreviousLicenceViewModel.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceViewModel.PreviousLicenceDescription))
            .ForMember(x => x.Deleted, opt => opt.Ignore())
            .ForMember(x => x.DateDeleted, opt => opt.Ignore());

            CreateMap <NamedJobTitleViewModel, NamedJobTitle>()
            .ForMember(x => x.Licence, opt => opt.Ignore())
            .ForMember(x => x.LicenceId, opt => opt.Ignore())
            .ForMember(x => x.Id, opt => opt.Ignore())
            .ForMember(x => x.JobTitle, opt => opt.MapFrom(y => y.JobTitle))
            .ForMember(x => x.JobTitleNumber, opt => opt.MapFrom(y => y.JobTitleNumber))
            .ForMember(x => x.Deleted, opt => opt.Ignore())
            .ForMember(x => x.DateDeleted, opt => opt.Ignore());

            CreateMap <NamedJobTitle, NamedJobTitleViewModel>()
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.ResolveUsing(x => ProfileHelpers.GetIsSubmitted(x.Licence)));

            CreateMap <ICollection <NamedIndividual>, NamedIndividualCollectionViewModel>()
            .ForMember(x => x.IsShellfish, opt => opt.Ignore())
            .ForMember(x => x.TurnoverBand, opt => opt.Ignore())
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.NamedIndividuals, opt => opt.MapFrom(y => y))
            .ForMember(x => x.NamedJobTitles, opt => opt.Ignore())
            .ForMember(x => x.IntroText, opt => opt.Ignore())
            .ForMember(x => x.NamedIndividualType, opt => opt.Ignore())
            .ForMember(x => x.NamedIndividualType, opt => opt.MapFrom(y => y.FirstOrDefault().Licence.NamedIndividualType))
            .ForMember(x => x.AvailableIndividualTypes, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.Ignore());

            CreateMap <ICollection <NamedJobTitle>, NamedIndividualCollectionViewModel>()
            .ForMember(x => x.IsShellfish, opt => opt.Ignore())
            .ForMember(x => x.TurnoverBand, opt => opt.Ignore())
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.NamedIndividuals, opt => opt.Ignore())
            .ForMember(x => x.NamedJobTitles, opt => opt.MapFrom(y => y))
            .ForMember(x => x.IntroText, opt => opt.Ignore())
            .ForMember(x => x.NamedIndividualType, opt => opt.Ignore())
            .ForMember(x => x.AvailableIndividualTypes, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.Ignore());

            CreateMap <FullNameViewModel, NamedIndividual>()
            .ForMember(x => x.FullName, opt => opt.MapFrom(y => y.FullName))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <DateOfBirthViewModel, NamedIndividual>()
            .ForMember(x => x.DateOfBirth, opt => opt.MapFrom(y => y.DateOfBirth.Date))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BusinessPhoneNumberViewModel, NamedIndividual>()
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.MapFrom(y => y.BusinessPhoneNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BusinessExtensionViewModel, NamedIndividual>()
            .ForMember(x => x.BusinessExtension, opt => opt.MapFrom(y => y.BusinessExtension))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <RightToWorkViewModel, NamedIndividual>()
            .ForMember(x => x.RequiresVisa, opt => opt.MapFrom(y => y.RequiresVisa))
            .ForMember(x => x.VisaDescription, opt => opt.MapFrom(y => y.VisaDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NamedIndividual, RightToWorkViewModel>()
            .ForMember(x => x.RequiresVisa, opt => opt.MapFrom(y => y.RequiresVisa))
            .ForMember(x => x.VisaDescription, opt => opt.MapFrom(y => y.VisaDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <UndischargedBankruptViewModel, NamedIndividual>()
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.BankruptcyDate))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.BankruptcyNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NamedIndividual, UndischargedBankruptViewModel>()
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.BankruptcyDate))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.BankruptcyNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <DisqualifiedDirectorViewModel, NamedIndividual>()
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualificationDetails))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NamedIndividual, DisqualifiedDirectorViewModel>()
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualificationDetails))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <RestraintOrdersViewModel, NamedIndividual>()
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.ResolveUsing(ProfileHelpers.RestraintOrdersResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NamedIndividual, RestraintOrdersViewModel>()
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.MapFrom(y => y.RestraintOrders.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <UnspentConvictionsViewModel, NamedIndividual>()
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.ResolveUsing(ProfileHelpers.UnspentConvictionsResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NamedIndividual, UnspentConvictionsViewModel>()
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.MapFrom(y => y.UnspentConvictions.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <OffencesAwaitingTrialViewModel, NamedIndividual>()
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.ResolveUsing(ProfileHelpers.OffencesAwaitingTrialResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NamedIndividual, OffencesAwaitingTrialViewModel>()
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.MapFrom(y => y.OffencesAwaitingTrial.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PreviousLicenceViewModel, NamedIndividual>()
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NamedIndividual, PreviousLicenceViewModel>()
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceDescription))
            .ForAllOtherMembers(opt => opt.Ignore());
        }
Beispiel #3
0
        public AlternativeBusinessRepresentativeProfile()
        {
            CreateMap <Licence, AlternativeBusinessRepresentativeCollectionViewModel>()
            .ForMember(x => x.AlternativeBusinessRepresentatives, opt => opt.MapFrom(y => y.AlternativeBusinessRepresentatives.Where(z => !z.Deleted)))
            .ForMember(x => x.HasAlternativeBusinessRepresentatives, opt => opt.MapFrom(y => y.HasAlternativeBusinessRepresentatives))
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.YesNo, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.ResolveUsing(ProfileHelpers.GetIsSubmitted));

            CreateMap <ICollection <AlternativeBusinessRepresentative>, AlternativeBusinessRepresentativeCollectionViewModel>()
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.HasAlternativeBusinessRepresentatives, opt => opt.MapFrom(y => y.FirstOrDefault().Licence.HasAlternativeBusinessRepresentatives))
            .ForMember(x => x.AlternativeBusinessRepresentatives, opt => opt.MapFrom(y => y.Where(z => !z.Deleted)))
            .ForMember(x => x.YesNo, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, AlternativeBusinessRepresentativeViewModel>()
            .ForMember(x => x.IsValid, opt => opt.Ignore())
            .ForMember(x => x.BirthDetailsViewModel, opt => opt.ResolveUsing(ProfileHelpers.BirthDetailsResolver <AlternativeBusinessRepresentativeViewModel>))
            .ForMember(x => x.FullName, opt => opt.ResolveUsing(ProfileHelpers.FullNameResolver))
            .ForMember(x => x.AlternativeName, opt => opt.ResolveUsing(ProfileHelpers.AlternativeFullNameResolver))
            .ForMember(x => x.JobTitle, opt => opt.ResolveUsing(ProfileHelpers.JobTitleResolver))
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.ResolveUsing(ProfileHelpers.BusinessPhoneNumberResolver))
            .ForMember(x => x.BusinessExtension, opt => opt.ResolveUsing(ProfileHelpers.BusinessExtensionResolver))
            .ForMember(x => x.PersonalMobileNumber, opt => opt.ResolveUsing(ProfileHelpers.PersonalMobileNumberResolver))
            .ForMember(x => x.PersonalEmailAddress, opt => opt.ResolveUsing(ProfileHelpers.PersonalEmailAddressResolver))
            .ForMember(x => x.Nationality, opt => opt.ResolveUsing(ProfileHelpers.NationalityResolver))
            .ForMember(x => x.PassportViewModel, opt => opt.ResolveUsing(ProfileHelpers.PassportViewModel))
            .ForMember(x => x.RightToWorkViewModel, opt => opt.ResolveUsing(ProfileHelpers.RightToWorkResolver))
            .ForMember(x => x.UndischargedBankruptViewModel, opt => opt.ResolveUsing(ProfileHelpers.UndischargedBankruptResolver))
            .ForMember(x => x.DisqualifiedDirectorViewModel, opt => opt.ResolveUsing(ProfileHelpers.DisqualifiedDirectorResolver))
            .ForMember(x => x.RestraintOrdersViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.UnspentConvictionsViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.OffencesAwaitingTrialViewModel, opt => opt.MapFrom(y => y))
            .ForMember(x => x.PreviousLicenceViewModel, opt => opt.ResolveUsing(ProfileHelpers.PreviousLicenceResolver))
            .ForMember(x => x.IsUk, opt => opt.MapFrom(y => y.CountryOfBirth != null && y.CountryOfBirth.IsUk))
            .ForMember(x => x.Countries, opt => opt.Ignore())
            .ForMember(x => x.Counties, opt => opt.Ignore())
            .ForMember(x => x.IsSubmitted, opt => opt.ResolveUsing(x => ProfileHelpers.GetIsSubmitted(x.Licence)))
            .ForMember(x => x.Address, opt => opt.Condition(y => y.Address != null));

            CreateMap <AlternativeBusinessRepresentative, AlternativeFullNameViewModel>()
            .ConvertUsing(ProfileHelpers.AlternativeFullNameResolver);

            CreateMap <AlternativeBusinessRepresentative, BirthDetailsViewModel>()
            .ConvertUsing(ProfileHelpers.BirthDetailsResolver);

            CreateMap <AlternativeBusinessRepresentativeViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.Licence, opt => opt.Ignore())
            .ForMember(x => x.LicenceId, opt => opt.Ignore())
            .ForMember(x => x.CountyOfBirth, opt => opt.Ignore())
            .ForMember(x => x.FullName, opt => opt.MapFrom(y => y.FullName.FullName))
            .ForMember(x => x.HasAlternativeName, opt => opt.MapFrom(y => y.AlternativeName.HasAlternativeName))
            .ForMember(x => x.AlternativeName, opt => opt.MapFrom(y => y.AlternativeName.AlternativeName))
            .ForMember(x => x.DateOfBirth, opt => opt.MapFrom(y => y.DateOfBirth.DateOfBirth.Date))
            .ForMember(x => x.TownOfBirth, opt => opt.MapFrom(y => y.BirthDetailsViewModel.TownOfBirthViewModel.TownOfBirth))
            .ForMember(x => x.CountryOfBirthId, opt => opt.MapFrom(y => y.BirthDetailsViewModel.CountryOfBirthViewModel.CountryOfBirthId))
            .ForMember(x => x.CountryOfBirth, opt => opt.Ignore())
            .ForMember(x => x.JobTitle, opt => opt.MapFrom(y => y.JobTitle.JobTitle))
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.MapFrom(y => y.BusinessPhoneNumber.BusinessPhoneNumber))
            .ForMember(x => x.BusinessExtension, opt => opt.MapFrom(y => y.BusinessExtension.BusinessExtension))
            .ForMember(x => x.PersonalEmailAddress, opt => opt.MapFrom(y => y.PersonalEmailAddress.PersonalEmailAddress))
            .ForMember(x => x.PersonalMobileNumber, opt => opt.MapFrom(y => y.PersonalMobileNumber.PersonalMobileNumber))
            .ForMember(x => x.NationalInsuranceNumber, opt => opt.MapFrom(y => y.BirthDetailsViewModel.NationalInsuranceNumberViewModel.NationalInsuranceNumber))
            .ForMember(x => x.SocialSecurityNumber, opt => opt.MapFrom(y => y.BirthDetailsViewModel.SocialSecurityNumberViewModel.SocialSecurityNumber))
            .ForMember(x => x.Nationality, opt => opt.MapFrom(y => y.Nationality.Nationality))
            .ForMember(x => x.HasPassport, opt => opt.MapFrom(y => y.PassportViewModel.HasPassport))
            .ForMember(x => x.RequiresVisa, opt => opt.MapFrom(y => y.RightToWorkViewModel.RequiresVisa))
            .ForMember(x => x.VisaDescription, opt => opt.MapFrom(y => y.RightToWorkViewModel.VisaDescription))
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.BankruptcyDate.Date))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.UndischargedBankruptViewModel.BankruptcyNumber))
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.DisqualifiedDirectorViewModel.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualifiedDirectorViewModel.DisqualificationDetails))
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.RestraintOrdersViewModel.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.Ignore())
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.UnspentConvictionsViewModel.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.Ignore())
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.OffencesAwaitingTrialViewModel.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.Ignore())
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.PreviousLicenceViewModel.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceViewModel.PreviousLicenceDescription))
            .ForMember(x => x.Deleted, opt => opt.Ignore())
            .ForMember(x => x.DateDeleted, opt => opt.Ignore());

            CreateMap <FullNameViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.FullName, opt => opt.MapFrom(y => y.FullName))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeFullNameViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.AlternativeName, opt => opt.MapFrom(y => y.AlternativeName))
            .ForMember(x => x.HasAlternativeName, opt => opt.MapFrom(y => y.HasAlternativeName))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <DateOfBirthViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.DateOfBirth, opt => opt.MapFrom(y => y.DateOfBirth.Date))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BirthDetailsViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.TownOfBirth, opt => opt.MapFrom(y => y.TownOfBirthViewModel.TownOfBirth))
            .ForMember(x => x.CountryOfBirthId, opt => opt.MapFrom(y => y.CountryOfBirthViewModel.CountryOfBirthId))
            .ForMember(x => x.NationalInsuranceNumber, opt => opt.MapFrom(y => y.NationalInsuranceNumberViewModel.NationalInsuranceNumber))
            .ForMember(x => x.SocialSecurityNumber, opt => opt.MapFrom(y => y.SocialSecurityNumberViewModel.SocialSecurityNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <JobTitleViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.JobTitle, opt => opt.MapFrom(y => y.JobTitle))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BusinessPhoneNumberViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.BusinessPhoneNumber, opt => opt.MapFrom(y => y.BusinessPhoneNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PersonalMobileNumberViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.PersonalMobileNumber, opt => opt.MapFrom(y => y.PersonalMobileNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PersonalEmailAddressViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.PersonalEmailAddress, opt => opt.MapFrom(y => y.PersonalEmailAddress))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <BusinessExtensionViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.BusinessExtension, opt => opt.MapFrom(y => y.BusinessExtension))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <NationalityViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.Nationality, opt => opt.MapFrom(y => y.Nationality))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, NationalityViewModel>()
            .ForMember(x => x.Nationality, opt => opt.MapFrom(y => y.Nationality))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PassportViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.HasPassport, opt => opt.MapFrom(y => y.HasPassport))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, PassportViewModel>()
            .ForMember(x => x.HasPassport, opt => opt.MapFrom(y => y.HasPassport))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <RightToWorkViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.RequiresVisa, opt => opt.MapFrom(y => y.RequiresVisa))
            .ForMember(x => x.VisaDescription, opt => opt.MapFrom(y => y.VisaDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, RightToWorkViewModel>()
            .ForMember(x => x.RequiresVisa, opt => opt.MapFrom(y => y.RequiresVisa))
            .ForMember(x => x.VisaDescription, opt => opt.MapFrom(y => y.VisaDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <UndischargedBankruptViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.BankruptcyDate))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.BankruptcyNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, UndischargedBankruptViewModel>()
            .ForMember(x => x.IsUndischargedBankrupt, opt => opt.MapFrom(y => y.IsUndischargedBankrupt))
            .ForMember(x => x.BankruptcyDate, opt => opt.MapFrom(y => y.BankruptcyDate))
            .ForMember(x => x.BankruptcyNumber, opt => opt.MapFrom(y => y.BankruptcyNumber))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <DisqualifiedDirectorViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualificationDetails))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, DisqualifiedDirectorViewModel>()
            .ForMember(x => x.IsDisqualifiedDirector, opt => opt.MapFrom(y => y.IsDisqualifiedDirector))
            .ForMember(x => x.DisqualificationDetails, opt => opt.MapFrom(y => y.DisqualificationDetails))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <RestraintOrdersViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.ResolveUsing(ProfileHelpers.RestraintOrdersResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, RestraintOrdersViewModel>()
            .ForMember(x => x.HasRestraintOrders, opt => opt.MapFrom(y => y.HasRestraintOrders))
            .ForMember(x => x.RestraintOrders, opt => opt.MapFrom(y => y.RestraintOrders.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <UnspentConvictionsViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.ResolveUsing(ProfileHelpers.UnspentConvictionsResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, UnspentConvictionsViewModel>()
            .ForMember(x => x.HasUnspentConvictions, opt => opt.MapFrom(y => y.HasUnspentConvictions))
            .ForMember(x => x.UnspentConvictions, opt => opt.MapFrom(y => y.UnspentConvictions.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <OffencesAwaitingTrialViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.ResolveUsing(ProfileHelpers.OffencesAwaitingTrialResolver))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, OffencesAwaitingTrialViewModel>()
            .ForMember(x => x.HasOffencesAwaitingTrial, opt => opt.MapFrom(y => y.HasOffencesAwaitingTrial))
            .ForMember(x => x.OffencesAwaitingTrial, opt => opt.MapFrom(y => y.OffencesAwaitingTrial.Where(z => !z.Deleted)))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <PreviousLicenceViewModel, AlternativeBusinessRepresentative>()
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceDescription))
            .ForAllOtherMembers(opt => opt.Ignore());

            CreateMap <AlternativeBusinessRepresentative, PreviousLicenceViewModel>()
            .ForMember(x => x.HasPreviouslyHeldLicence, opt => opt.MapFrom(y => y.HasPreviouslyHeldLicence))
            .ForMember(x => x.PreviousLicenceDescription, opt => opt.MapFrom(y => y.PreviousLicenceDescription))
            .ForAllOtherMembers(opt => opt.Ignore());
        }