public IDataEntity BuildLearningDeliveryDataEntity(ILearningDelivery learningDelivery) { var learningDeliveryFAMDenormalized = BuildLearningDeliveryFAMDenormalized(learningDelivery.LearningDeliveryFAMs); var larsLearningDelivery = _larsReferenceDataService.LARSLearningDeliveryForLearnAimRef(learningDelivery.LearnAimRef); var larsStandardCommonComponent = _larsReferenceDataService.LARSStandardCommonComponent(learningDelivery.StdCodeNullable); var larsStandardFunding = _larsReferenceDataService.LARSStandardFunding(learningDelivery.StdCodeNullable); return(new DataEntity(Attributes.EntityLearningDelivery) { Attributes = new Dictionary <string, IAttributeData>() { { Attributes.AchDate, new AttributeData(learningDelivery.AchDateNullable) }, { Attributes.AimSeqNumber, new AttributeData(learningDelivery.AimSeqNumber) }, { Attributes.AimType, new AttributeData(learningDelivery.AimType) }, { Attributes.CompStatus, new AttributeData(learningDelivery.CompStatus) }, { Attributes.FrameworkCommonComponent, new AttributeData(larsLearningDelivery.FrameworkCommonComponent) }, { Attributes.LearnAimRef, new AttributeData(learningDelivery.LearnAimRef) }, { Attributes.LearnActEndDate, new AttributeData(learningDelivery.LearnActEndDateNullable) }, { Attributes.LearnPlanEndDate, new AttributeData(learningDelivery.LearnPlanEndDate) }, { Attributes.LearnStartDate, new AttributeData(learningDelivery.LearnStartDate) }, { Attributes.LrnDelFAM_EEF, new AttributeData(learningDeliveryFAMDenormalized.EEF) }, { Attributes.LrnDelFAM_FFI, new AttributeData(learningDeliveryFAMDenormalized.FFI) }, { Attributes.LrnDelFAM_LDM1, new AttributeData(learningDeliveryFAMDenormalized.LDM1) }, { Attributes.LrnDelFAM_LDM2, new AttributeData(learningDeliveryFAMDenormalized.LDM2) }, { Attributes.LrnDelFAM_LDM3, new AttributeData(learningDeliveryFAMDenormalized.LDM3) }, { Attributes.LrnDelFAM_LDM4, new AttributeData(learningDeliveryFAMDenormalized.LDM4) }, { Attributes.LrnDelFAM_RES, new AttributeData(learningDeliveryFAMDenormalized.RES) }, { Attributes.LrnDelFAM_SOF, new AttributeData(learningDeliveryFAMDenormalized.SOF) }, { Attributes.LrnDelFAM_SPP, new AttributeData(learningDeliveryFAMDenormalized.SPP) }, { Attributes.OrigLearnStartDate, new AttributeData(learningDelivery.OrigLearnStartDateNullable) }, { Attributes.OtherFundAdj, new AttributeData(learningDelivery.OtherFundAdjNullable) }, { Attributes.Outcome, new AttributeData(learningDelivery.OutcomeNullable) }, { Attributes.PriorLearnFundAdj, new AttributeData(learningDelivery.PriorLearnFundAdjNullable) }, { Attributes.ProgType, new AttributeData(learningDelivery.ProgTypeNullable) }, { Attributes.STDCode, new AttributeData(learningDelivery.StdCodeNullable) }, { Attributes.WithdrawReason, new AttributeData(learningDelivery.WithdrawReasonNullable) }, }, Children = ( learningDelivery? .LearningDeliveryFAMs? .Select(BuildLearningDeliveryFAM) ?? new List <IDataEntity>()) .Union( learningDelivery? .AppFinRecords? .Select(BuildApprenticeshipFinancialRecord) ?? new List <IDataEntity>()) .Union( larsStandardCommonComponent? .Select(BuildLARSStandardCommonComponent) ?? new List <IDataEntity>()) .Union( larsStandardFunding? .Select(BuildLARSStandardFunding) ?? new List <IDataEntity>()) .ToList() }); }