public TrainingProviderDetailsViewModel Map(ApprenticeshipProviderDetailResponse source, string apprenticeshipId) { var employerSatisfationMessage = (source.ApprenticeshipDetails.Product.EmployerSatisfaction > 0) ? ProviderMappingHelper.GetPercentageText(source.ApprenticeshipDetails.Product.EmployerSatisfaction) : ProviderMappingHelper.GetPercentageText(null); var learnerSatisfationMessage = (source.ApprenticeshipDetails.Product.LearnerSatisfaction > 0) ? ProviderMappingHelper.GetPercentageText(source.ApprenticeshipDetails.Product.LearnerSatisfaction) : ProviderMappingHelper.GetPercentageText(null); var item = new TrainingProviderDetailsViewModel() { ContactInformation = new ContactInformation() { Email = source.ApprenticeshipDetails.Provider.ContactInformation.Email, Phone = source.ApprenticeshipDetails.Provider.ContactInformation.Phone, Website = source.ApprenticeshipDetails.Provider.ContactInformation.Website, ContactUsUrl = source.ApprenticeshipDetails.Provider.ContactInformation.ContactUsUrl }, CurrentlyNotStartingNewApprentices = source.ApprenticeshipDetails.Provider.CurrentlyNotStartingNewApprentices, EmployerSatisfaction = Convert.ToInt32(source.ApprenticeshipDetails.Product.EmployerSatisfaction ?? 0.00), EmployerSatisfactionMessage = employerSatisfationMessage, IsHigherEducationInstitute = source.ApprenticeshipDetails.Provider.IsHigherEducationInstitute, LearnerSatisfaction = Convert.ToInt32(source.ApprenticeshipDetails.Product.LearnerSatisfaction ?? 0.00), LearnerSatisfactionMessage = learnerSatisfationMessage, NationalProvider = source.ApprenticeshipDetails.Provider.NationalProvider, Ukprn = source.ApprenticeshipDetails.Provider.UkPrn, Name = source.ApprenticeshipDetails.Provider.Name, DeliveryModes = source.ApprenticeshipDetails.Product.DeliveryModes, MarketingInfo = source.ApprenticeshipDetails.Product.ProviderMarketingInfo, HasParentCompanyGuarantee = source.ApprenticeshipDetails.Provider.HasParentCompanyGuarantee, IsNewProvider = source.ApprenticeshipDetails.Provider.IsNew, IsLevyPayerOnly = source.ApprenticeshipDetails.Provider.IsLevyPayerOnly, AchievementRate = Convert.ToInt32(source.ApprenticeshipDetails.Product.AchievementRate), NationalAchievementRate = Convert.ToInt32(source.ApprenticeshipDetails.Product.NationalAchievementRate), LocationAddressLine = ProviderMappingHelper.GetCommaList(source.ApprenticeshipDetails.Location.LocationName, source.ApprenticeshipDetails.Location.Address.Address1, source.ApprenticeshipDetails.Location.Address.Address2, source.ApprenticeshipDetails.Location.Address.Town, source.ApprenticeshipDetails.Location.Address.County, source.ApprenticeshipDetails.Location.Address.Postcode), LegalName = source.ApprenticeshipDetails.Provider.LegalName, Feedback = _feedbackMapper.Map(source.ApprenticeshipDetails.Provider.ProviderFeedback), AboutApprenticeshipInfo = source.ApprenticeshipDetails.Product.Apprenticeship.ApprenticeshipMarketingInfo, Postcode = source.ApprenticeshipDetails.Location.Address.Postcode, Location = source.ApprenticeshipDetails.Location, ApprenticeshipId = apprenticeshipId }; return(item); }
private static void CreateProviderDetailsMappings(IMapperConfiguration cfg) { cfg.CreateMap <StatsResponse, StatsViewModel>() .ForMember(dest => dest.StandardCount, opt => opt.MapFrom(source => source.StandardCount)) .ForMember(dest => dest.FrameworkCount, opt => opt.MapFrom(source => source.FrameworkCount)) .ForMember(dest => dest.ProviderCount, opt => opt.MapFrom(source => source.ProviderCount)) .ForMember(dest => dest.StandardOffer, opt => opt.MapFrom(source => source.StandardOffer)) .ForMember(dest => dest.FrameworkOffer, opt => opt.MapFrom(source => source.FrameworkOffer)) .ForMember(dest => dest.ExpiringFrameworks30, opt => opt.MapFrom(source => source.ExpiringFrameworks30)) .ForMember(dest => dest.ExpiringFrameworks90, opt => opt.MapFrom(source => source.ExpiringFrameworks90)) .ForMember(dest => dest.StandardsWithProviders, opt => opt.MapFrom(source => source.StandardsWithProviders)) .ForMember(dest => dest.StandardsWithoutProviders, opt => opt.MapFrom(source => source.StandardsWithoutProviders)) .ForMember(dest => dest.FrameworksWithProviders, opt => opt.MapFrom(source => source.FrameworksWithProviders)) .ForMember(dest => dest.FrameworksWithoutProviders, opt => opt.MapFrom(source => source.FrameworksWithoutProviders)) ; cfg.CreateMap <ApprenticeshipProviderDetailResponse, ApprenticeshipDetailsViewModel>() .ForMember(dest => dest.Address, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Location.Address)) .ForMember(dest => dest.Apprenticeship, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Product.Apprenticeship)) .ForMember(dest => dest.ContactInformation, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.ContactInformation)) .ForMember(dest => dest.CurrentlyNotStartingNewApprentices, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.CurrentlyNotStartingNewApprentices)) .ForMember(dest => dest.DeliveryModes, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Product.DeliveryModes)) .ForMember(dest => dest.Location, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Location)) .ForMember(dest => dest.Name, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.Name)) .ForMember(dest => dest.LegalName, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.LegalName)) .ForMember(dest => dest.NationalProvider, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.NationalProvider)) .ForMember(dest => dest.Ukprn, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.UkPrn)) .ForMember(dest => dest.IsHigherEducationInstitute, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.IsHigherEducationInstitute)) .ForMember(dest => dest.IsLevyPayerOnly, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Provider.IsLevyPayerOnly)) .ForMember(dest => dest.EmployerSatisfaction, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Product.EmployerSatisfaction)) .ForMember(dest => dest.LearnerSatisfaction, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Product.LearnerSatisfaction)) .ForMember(dest => dest.ProviderMarketingInfo, opt => opt.MapFrom(source => source.ApprenticeshipDetails.Product.ProviderMarketingInfo)) .ForMember(dest => dest.RegulatedApprenticeship, opt => opt.MapFrom(source => source.RegulatedApprenticeship)) .ForMember(x => x.EmployerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.ApprenticeshipDetails.Product.EmployerSatisfaction, z.ApprenticeshipDetails.Provider.IsHigherEducationInstitute))) .ForMember(x => x.LearnerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.ApprenticeshipDetails.Product.LearnerSatisfaction, z.ApprenticeshipDetails.Provider.IsHigherEducationInstitute))) .ForMember(dest => dest.SurveyUrl, y => y.Ignore()) .ForMember(dest => dest.SatisfactionSourceUrl, y => y.Ignore()) .ForMember(dest => dest.AchievementRateSourceUrl, y => y.Ignore()) .ForMember(x => x.AchievementRateMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.ApprenticeshipDetails.Product.AchievementRate))) .ForMember(x => x.AchievementRate, y => y.MapFrom(z => z.ApprenticeshipDetails.Product.AchievementRate)) .ForMember(x => x.NationalAchievementRateMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.ApprenticeshipDetails.Product.NationalAchievementRate))) .ForMember(x => x.NationalAchievementRate, y => y.MapFrom(z => z.ApprenticeshipDetails.Product.NationalAchievementRate)) .ForMember(x => x.OverallCohort, y => y.ResolveUsing <OverallCohortResolver>().FromMember(z => z.ApprenticeshipDetails.Product.OverallCohort)) .ForMember(x => x.ApprenticeshipName, y => y.MapFrom(z => ApprenticeshipMappingHelper.FrameworkTitle(z.ApprenticeshipName))) .ForMember(x => x.LocationAddressLine, y => y.MapFrom(z => ProviderMappingHelper.GetCommaList(z.ApprenticeshipDetails.Location.LocationName, z.ApprenticeshipDetails.Location.Address.Address1, z.ApprenticeshipDetails.Location.Address.Address2, z.ApprenticeshipDetails.Location.Address.Town, z.ApprenticeshipDetails.Location.Address.County, z.ApprenticeshipDetails.Location.Address.Postcode))) .ForMember(x => x.HasParentCompanyGuarantee, y => y.MapFrom(z => z.ApprenticeshipDetails.Provider.HasParentCompanyGuarantee)) .ForMember(x => x.IsNewProvider, y => y.MapFrom(z => z.ApprenticeshipDetails.Provider.IsNew)) .ForMember(x => x.HasNonLevyContract, y => y.MapFrom(z => z.ApprenticeshipDetails.Provider.HasNonLevyContract)) .ForMember(x => x.IsLevyPayingEmployer, y => y.Ignore()) .ForMember(dest => dest.ManageApprenticeshipFunds, opt => opt.Ignore()) .ForMember(dest => dest.SearchTerm, opt => opt.Ignore()) .ForMember(dest => dest.ApprenticeshipId, opt => opt.Ignore()) .ForMember(dest => dest.Postcode, opt => opt.Ignore()) .ForMember(dest => dest.Feedback, y => y.MapFrom(z => z.ApprenticeshipDetails.Provider.ProviderFeedback != null ? new FeedbackViewModel(z.ApprenticeshipDetails.Provider.ProviderFeedback) : (FeedbackViewModel)null)) ; cfg.CreateMap <IApprenticeshipProviderSearchResultsItem, StandardProviderResultItemViewModel>() .ForMember(x => x.EmployerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.EmployerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.LearnerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.LearnerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.LocationAddressLine, y => y.Ignore()) .ForMember(x => x.NationalProvider, y => y.Ignore()) .ForMember(x => x.AchievementRateMessage, y => y.Ignore()) .ForMember(x => x.StandardCode, y => y.Ignore()) .ForMember(x => x.DeliveryOptionsMessage, y => y.Ignore()) .ForMember(x => x.LocationId, y => y.Ignore()) .ForMember(x => x.LocationName, y => y.Ignore()) .ForMember(x => x.Address, y => y.Ignore()) ; // ToDo: Do we need to specify if mapping is defined in concrete class? cfg.CreateMap <IApprenticeshipProviderSearchResultsItem, FrameworkProviderResultItemViewModel>() .ForMember(x => x.EmployerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.EmployerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.LearnerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.LearnerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.LocationAddressLine, y => y.Ignore()) .ForMember(x => x.NationalProvider, y => y.Ignore()) .ForMember(x => x.AchievementRateMessage, y => y.Ignore()) .ForMember(x => x.PathwayCode, y => y.Ignore()) .ForMember(x => x.Level, y => y.Ignore()) .ForMember(x => x.FrameworkId, y => y.Ignore()) .ForMember(x => x.FrameworkCode, y => y.Ignore()) .ForMember(x => x.DeliveryOptionsMessage, y => y.Ignore()) .ForMember(x => x.LocationId, y => y.Ignore()) .ForMember(x => x.LocationName, y => y.Ignore()) .ForMember(x => x.Address, y => y.Ignore()) .ForMember(x => x.CurrentlyNotStartingNewApprentices, y => y.Ignore()) ; cfg.CreateMap <ProviderSearchResultItem, StandardProviderResultItemViewModel>() .ForMember(x => x.EmployerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.EmployerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.LearnerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.LearnerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.AchievementRateMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.OverallAchievementRate))) .ForMember(x => x.LocationAddressLine, y => y.MapFrom(z => ProviderMappingHelper.GetLocationAddressLine(z))) .ForMember(x => x.DeliveryOptionsMessage, y => y.ResolveUsing <DeliveryOptionResolver>().FromMember(z => z.DeliveryModes)) .ForMember(x => x.LocationId, y => y.MapFrom(z => z.LocationId)) .ForMember(x => x.LocationName, y => y.MapFrom(z => z.LocationName)) .ForMember(x => x.Address, y => y.MapFrom(z => z.Address)) .ForMember(x => x.StandardCode, y => y.Ignore()) .ForMember(x => x.MarketingName, y => y.Ignore()) .ForMember(x => x.Phone, y => y.Ignore()) .ForMember(x => x.Email, y => y.Ignore()) .ForMember(x => x.ContactUsUrl, y => y.Ignore()) .ForMember(x => x.Website, y => y.Ignore()) .ForMember(x => x.CurrentlyNotStartingNewApprentices, y => y.Ignore()) ; cfg.CreateMap <ProviderSearchResultItem, FrameworkProviderResultItemViewModel>() .ForMember(x => x.EmployerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.EmployerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.LearnerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.LearnerSatisfaction, z.IsHigherEducationInstitute))) .ForMember(x => x.AchievementRateMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.OverallAchievementRate))) .ForMember(x => x.LocationAddressLine, y => y.MapFrom(z => ProviderMappingHelper.GetLocationAddressLine(z))) .ForMember(x => x.DeliveryOptionsMessage, y => y.ResolveUsing <DeliveryOptionResolver>().FromMember(z => z.DeliveryModes)) .ForMember(x => x.LocationId, y => y.MapFrom(z => z.LocationId)) .ForMember(x => x.LocationName, y => y.MapFrom(z => z.LocationName)) .ForMember(x => x.Address, y => y.MapFrom(z => z.Address)) .ForMember(x => x.CurrentlyNotStartingNewApprentices, y => y.Ignore()) .ForMember(x => x.FrameworkCode, y => y.Ignore()) .ForMember(x => x.PathwayCode, y => y.Ignore()) .ForMember(x => x.Level, y => y.Ignore()) .ForMember(x => x.MarketingName, y => y.Ignore()) .ForMember(x => x.ProviderMarketingInfo, y => y.Ignore()) .ForMember(x => x.ApprenticeshipMarketingInfo, y => y.Ignore()) .ForMember(x => x.Phone, y => y.Ignore()) .ForMember(x => x.Email, y => y.Ignore()) .ForMember(x => x.ContactUsUrl, y => y.Ignore()) .ForMember(x => x.ApprenticeshipInfoUrl, y => y.Ignore()) .ForMember(x => x.Website, y => y.Ignore()) .ForMember(x => x.FrameworkId, y => y.Ignore()) ; // Provider detail page cfg.CreateMap <ApprenticeshipDetails, ApprenticeshipDetailsViewModel>() .ForMember(dest => dest.Address, opt => opt.MapFrom(source => source.Location.Address)) .ForMember(dest => dest.Apprenticeship, opt => opt.MapFrom(source => source.Product.Apprenticeship)) .ForMember(dest => dest.Apprenticeship, opt => opt.MapFrom(source => source.Product.Apprenticeship)) .ForMember(dest => dest.ContactInformation, opt => opt.MapFrom(source => source.Provider.ContactInformation)) .ForMember(dest => dest.CurrentlyNotStartingNewApprentices, opt => opt.MapFrom(source => source.Provider.CurrentlyNotStartingNewApprentices)) .ForMember(dest => dest.DeliveryModes, opt => opt.MapFrom(source => source.Product.DeliveryModes)) .ForMember(dest => dest.Location, opt => opt.MapFrom(source => source.Location)) .ForMember(dest => dest.Name, opt => opt.MapFrom(source => source.Provider.Name)) .ForMember(dest => dest.LegalName, opt => opt.MapFrom(source => source.Provider.LegalName)) .ForMember(dest => dest.NationalProvider, opt => opt.MapFrom(source => source.Provider.NationalProvider)) .ForMember(dest => dest.Ukprn, opt => opt.MapFrom(source => source.Provider.UkPrn)) .ForMember(dest => dest.IsHigherEducationInstitute, opt => opt.MapFrom(source => source.Provider.IsHigherEducationInstitute)) .ForMember(dest => dest.IsLevyPayerOnly, opt => opt.MapFrom(source => source.Provider.IsLevyPayerOnly)) .ForMember(dest => dest.EmployerSatisfaction, opt => opt.MapFrom(source => source.Product.EmployerSatisfaction)) .ForMember(dest => dest.LearnerSatisfaction, opt => opt.MapFrom(source => source.Product.LearnerSatisfaction)) .ForMember(dest => dest.ProviderMarketingInfo, opt => opt.MapFrom(source => source.Product.ProviderMarketingInfo)) .ForMember(x => x.EmployerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.Product.EmployerSatisfaction, z.Provider.IsHigherEducationInstitute))) .ForMember(x => x.LearnerSatisfactionMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.Product.LearnerSatisfaction, z.Provider.IsHigherEducationInstitute))) .ForMember(x => x.ApprenticeshipName, y => y.Ignore()) .ForMember(x => x.ApprenticeshipLevel, y => y.Ignore()) .ForMember(x => x.ApprenticeshipType, y => y.Ignore()) .ForMember(x => x.SatisfactionSourceUrl, y => y.Ignore()) .ForMember(x => x.AchievementRateSourceUrl, y => y.Ignore()) .ForMember(x => x.RegulatedApprenticeship, y => y.Ignore()) .ForMember(x => x.SurveyUrl, y => y.Ignore()) .ForMember(x => x.AchievementRateMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.Product.AchievementRate))) .ForMember(x => x.AchievementRate, y => y.MapFrom(z => z.Product.AchievementRate)) .ForMember(x => x.NationalAchievementRateMessage, y => y.MapFrom(z => ProviderMappingHelper.GetPercentageText(z.Product.NationalAchievementRate))) .ForMember(x => x.NationalAchievementRate, y => y.MapFrom(z => z.Product.NationalAchievementRate)) .ForMember(x => x.OverallCohort, y => y.ResolveUsing <OverallCohortResolver>().FromMember(z => z.Product.OverallCohort)) .ForMember(x => x.LocationAddressLine, y => y.MapFrom(z => ProviderMappingHelper.GetCommaList(z.Location.LocationName, z.Location.Address.Address1, z.Location.Address.Address2, z.Location.Address.Town, z.Location.Address.County, z.Location.Address.Postcode))) .ForMember(x => x.HasParentCompanyGuarantee, y => y.MapFrom(z => z.Provider.HasParentCompanyGuarantee)) .ForMember(x => x.IsNewProvider, y => y.MapFrom(z => z.Provider.IsNew)) .ForMember(x => x.HasNonLevyContract, y => y.MapFrom(z => z.Provider.HasNonLevyContract)) .ForMember(x => x.IsLevyPayingEmployer, y => y.Ignore()) .ForMember(dest => dest.ManageApprenticeshipFunds, opt => opt.Ignore()) .ForMember(x => x.SearchTerm, y => y.Ignore()) .ForMember(x => x.ApprenticeshipId, y => y.Ignore()) .ForMember(x => x.Postcode, y => y.Ignore()) .ForMember(dest => dest.Feedback, y => y.MapFrom(z => z.Provider.ProviderFeedback != null ? new FeedbackViewModel(z.Provider.ProviderFeedback) : (FeedbackViewModel)null)) .AfterMap <ProviderViewModelMappingAction>(); }
protected override string ResolveCore(double?satisfaction) { return(ProviderMappingHelper.GetPercentageText(satisfaction)); }
public void Process(ApprenticeshipDetails source, ApprenticeshipDetailsViewModel destination) { destination.EmployerSatisfactionMessage = ProviderMappingHelper.GetPercentageText(source.Product.EmployerSatisfaction); destination.LearnerSatisfactionMessage = ProviderMappingHelper.GetPercentageText(source.Product.LearnerSatisfaction); }
public void WhenGetPercentageText(double?input, bool hei, string expected) { ProviderMappingHelper.GetPercentageText(input, hei).Should().BeEquivalentTo(expected); }