Example #1
0
        private InvalidLearnerData PopulateInvalidLearners(int ukprn, IEnumerable <ILearner> learners, IEnumerable <ILearnerDestinationAndProgression> learnerDestinationAndProgressions)
        {
            var invalidLearnerData = new InvalidLearnerData();

            int learnerId                           = 1;
            int learnerDeliveryId                   = 1;
            int learnerEmploymentStatusId           = 1;
            int learnerEmploymentStatusMonitoringId = 1;
            int learningDeliveryHEId                = 1;
            int learnerDeliveryFamId                = 1;
            int appFinRecordId                      = 1;
            int learningDeliveryWorkPlacementId     = 1;
            int learnerFAMId                        = 1;
            int learnerHEId                         = 1;
            int learnerHEFinancialSupportId         = 1;
            int providerSpecLearnerMonitoringId     = 1;
            int providerSpecDeliveryMonitoringId    = 1;
            int contactPreferenceId                 = 1;
            int lLDDandHealthProblemID              = 1;
            int learnerDestinationandProgressionId  = 1;
            int dPOutcomeId                         = 1;

            learners.NullSafeForEach(learner =>
            {
                invalidLearnerData.RecordsInvalidLearners.Add(LearnerBuilder.BuildInvalidLearner(ukprn, learner, learnerId));

                learner.ContactPreferences.NullSafeForEach(
                    contactPreference =>
                    PopulateContactPreferences(ukprn, learner, contactPreference, learnerId, contactPreferenceId++, invalidLearnerData));

                learner.LearningDeliveries.NullSafeForEach(learningDelivery =>
                {
                    PopulateLearningDelivery(ukprn, learner, learningDelivery, learnerId, learnerDeliveryId, invalidLearnerData);

                    if (learningDelivery.LearningDeliveryHEEntity != null)
                    {
                        PopulateLearningDeliveryHERecord(ukprn, learner, learningDelivery, learningDelivery.LearningDeliveryHEEntity, learningDeliveryHEId++, invalidLearnerData);
                    }

                    learningDelivery.AppFinRecords.NullSafeForEach(
                        appFinRecord =>
                        PopulateLearningDeliveryAppFinRecord(ukprn, learner, learningDelivery, appFinRecord, learnerDeliveryId, appFinRecordId++, invalidLearnerData));

                    learningDelivery.LearningDeliveryFAMs.NullSafeForEach(
                        famRecord =>
                        PopulateLearningDeliveryFAMRecord(ukprn, learner, learningDelivery, famRecord, learnerDeliveryId, learnerDeliveryFamId++, invalidLearnerData));

                    learningDelivery.LearningDeliveryWorkPlacements.NullSafeForEach(workPlacement =>
                                                                                    PopulateLearningDeliveryWorkPlacement(ukprn, learner, learningDelivery, workPlacement, learnerDeliveryId, learningDeliveryWorkPlacementId++, invalidLearnerData));

                    learningDelivery.ProviderSpecDeliveryMonitorings.NullSafeForEach(monitoring =>
                                                                                     PopulateProviderSpecDeliveryMonitoring(ukprn, learner, learningDelivery, monitoring, learnerDeliveryId, providerSpecDeliveryMonitoringId++, invalidLearnerData));

                    learnerDeliveryId++;
                });

                learner.LearnerEmploymentStatuses.NullSafeForEach(employmentStatus =>
                {
                    PopulateLearnerEmploymentStatus(ukprn, learner, employmentStatus, learnerId, learnerEmploymentStatusId, invalidLearnerData);

                    employmentStatus.EmploymentStatusMonitorings?.ToList()
                    .ForEach(monitoring =>
                             PopulateEmploymentStatusMonitoring(ukprn, learner, employmentStatus, monitoring, learnerEmploymentStatusId, learnerEmploymentStatusMonitoringId++, invalidLearnerData));

                    learnerEmploymentStatusId++;
                });

                learner.LearnerFAMs.NullSafeForEach(fam => PopulateLearnerFAM(ukprn, learner, fam, learnerId, learnerFAMId++, invalidLearnerData));

                if (learner.LearnerHEEntity != null)
                {
                    PopulateLearnerHE(ukprn, learner, learnerId, learnerHEId++, invalidLearnerData);

                    learner.LearnerHEEntity.LearnerHEFinancialSupports.NullSafeForEach(support => PopulateLearnerHEFinancialSupport(ukprn, learner, support, learnerHEFinancialSupportId++, invalidLearnerData));
                }

                learner.LLDDAndHealthProblems.NullSafeForEach(problem => PopulateLLDDAndHealthProblem(ukprn, learner, problem, learnerId, lLDDandHealthProblemID++, invalidLearnerData));

                learner.ProviderSpecLearnerMonitorings.NullSafeForEach(monitoring => PopulateProviderSpecLearnerMonitorings(ukprn, learner, monitoring, learnerId, providerSpecLearnerMonitoringId++, invalidLearnerData));

                learnerId++;
            });

            learnerDestinationAndProgressions.NullSafeForEach(learnerDestinationAndProgression =>
            {
                invalidLearnerData.RecordsInvalidLearnerDestinationandProgressions.Add(new EF.Invalid.LearnerDestinationandProgression
                {
                    LearnerDestinationandProgression_Id = learnerDestinationandProgressionId,
                    UKPRN          = ukprn,
                    LearnRefNumber = learnerDestinationAndProgression.LearnRefNumber,
                    ULN            = learnerDestinationAndProgression.ULN
                });

                learnerDestinationAndProgression.DPOutcomes.NullSafeForEach(dpOutcome =>
                {
                    invalidLearnerData.RecordsInvalidDpOutcomes.Add(new EF.Invalid.DPOutcome
                    {
                        DPOutcome_Id = dPOutcomeId,
                        LearnerDestinationandProgression_Id = learnerDestinationandProgressionId,
                        LearnRefNumber = learnerDestinationAndProgression.LearnRefNumber,
                        OutCode        = dpOutcome.OutCode,
                        UKPRN          = ukprn,
                        OutCollDate    = dpOutcome.OutCollDate,
                        OutEndDate     = dpOutcome.OutEndDateNullable,
                        OutStartDate   = dpOutcome.OutStartDate,
                        OutType        = dpOutcome.OutType
                    });

                    dPOutcomeId++;
                });

                learnerDestinationandProgressionId++;
            });

            return(invalidLearnerData);
        }