private async Task PrePopulateReferenceDataCache(
            SupplementaryDataWrapper wrapper,
            ISourceFileModel sourceFile,
            CancellationToken cancellationToken)
        {
            var allUlns = wrapper.SupplementaryDataModels.Select(m => m.ULN).ToList();

            _populationService.PrePopulateUlnCache(allUlns, cancellationToken);

            var ukPrn = Convert.ToInt32(sourceFile.UKPRN);

            _populationService.PrePopulateContractAllocations(ukPrn, wrapper.SupplementaryDataModels, cancellationToken);

            await _populationService.PrePopulateContractDeliverableUnitCosts(ukPrn, cancellationToken);

            var deliverableCodes = wrapper.SupplementaryDataModels.Select(m => m.DeliverableCode).ToList();

            _populationService.PrePopulateContractDeliverableCodeMappings(deliverableCodes, cancellationToken);

            var learnAimRefs = wrapper.SupplementaryDataModels.Select(m => m.LearnAimRef).ToList();
            await _populationService.PrePopulateLarsLearningDeliveries(learnAimRefs, cancellationToken);

            await _populationService.PrePopulateValidationErrorMessages(cancellationToken);
        }
        public void ValidateData(
            SupplementaryDataWrapper wrapper,
            SourceFileModel sourceFile,
            CancellationToken cancellationToken)
        {
            foreach (var looseModel in wrapper.SupplementaryDataLooseModels)
            {
                if (_looseValidatorCommand.Execute(looseModel))
                {
                    continue;
                }

                foreach (var error in _looseValidatorCommand.Errors)
                {
                    wrapper.ValidErrorModels.Add(error);
                }

                if (!_looseValidatorCommand.RejectFile)
                {
                    continue;
                }

                return;
            }

            wrapper.SupplementaryDataLooseModels = FilterOutInvalidLooseRows(wrapper);

            wrapper.SupplementaryDataModels = wrapper.SupplementaryDataLooseModels.Select(m => _mapper.GetSupplementaryDataModelFromLooseModel(m)).ToList();

            var allUlns = wrapper.SupplementaryDataModels.Select(m => m.ULN).ToList();

            _populationService.PrePopulateUlnCache(allUlns, cancellationToken);

            var ukPrn = Convert.ToInt64(sourceFile.UKPRN);

            _populationService.PrePopulateContractAllocations(ukPrn, wrapper.SupplementaryDataModels, cancellationToken);

            foreach (var command in _validatorCommands)
            {
                if (command is ICrossRecordCommand)
                {
                    ((ICrossRecordCommand)command).AllRecords = wrapper.SupplementaryDataModels;
                }

                foreach (var model in wrapper.SupplementaryDataModels)
                {
                    if (command.Execute(model))
                    {
                        continue;
                    }

                    foreach (var error in command.Errors)
                    {
                        wrapper.ValidErrorModels.Add(error);
                    }

                    if (!command.RejectFile)
                    {
                        continue;
                    }

                    RejectFile = true;
                    return;
                }
            }

            wrapper.SupplementaryDataModels = FilterOutInvalidRows(wrapper);
        }