Exemple #1
0
        public void Validate(ILearner objectToValidate)
        {
            if (objectToValidate.LearningDeliveries == null)
            {
                return;
            }

            var ukprn            = _fileDataService.UKPRN();
            var longTermResUkprn = _organisationDataService.IsLongTermResForUkprn(ukprn);

            foreach (var learningDelivery in objectToValidate.LearningDeliveries)
            {
                var devolvedPostcodes = _postcodesDataService.GetDevolvedPostcodes(learningDelivery.LSDPostcode);
                var dd35 = _dd35.IsCombinedAuthorities(learningDelivery);

                foreach (var sofLdFams in _learningDeliveryFAMQueryService.GetLearningDeliveryFAMsForType(learningDelivery?.LearningDeliveryFAMs, LearningDeliveryFAMTypeConstants.SOF))
                {
                    if (
                        ConditionMet(
                            learningDelivery.LearnStartDate,
                            learningDelivery.FundModel,
                            learningDelivery.ProgTypeNullable,
                            learningDelivery.LSDPostcode,
                            devolvedPostcodes,
                            dd35,
                            sofLdFams.LearnDelFAMCode,
                            learningDelivery.LearningDeliveryFAMs,
                            longTermResUkprn))
                    {
                        HandleValidationError(
                            objectToValidate.LearnRefNumber,
                            learningDelivery.AimSeqNumber,
                            errorMessageParameters: BuildErrorMessageParameters(
                                learningDelivery.LearnStartDate,
                                learningDelivery.FundModel,
                                learningDelivery.LSDPostcode,
                                LearningDeliveryFAMTypeConstants.SOF,
                                sofLdFams.LearnDelFAMCode));
                    }
                }
            }
        }