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

            foreach (var learningDelivery in learner.LearningDeliveries)
            {
                var latestLearningStart = _derivedData22.GetLatestLearningStartForESFContract(learningDelivery, learner.LearningDeliveries);

                var partnerships = _fcsDataService.GetEligibilityRuleEnterprisePartnershipsFor(learningDelivery.ConRefNumber);

                if (!partnerships.Any())
                {
                    break;
                }

                var onsPostCode = _postcodeService.GetONSPostcodes(learningDelivery.DelLocPostCode);
                var onsPostcodesMatchinglocalEnterprisePartnerships = onsPostCode
                                                                      .Where(pc => partnerships.Any(lep => lep.Code.CaseInsensitiveEquals(pc.Lep1) || lep.Code.CaseInsensitiveEquals(pc.Lep2)));

                if (ConditionMetDD22Exists(latestLearningStart) &&
                    ConditionMetStartDate(learningDelivery.LearnStartDate) &&
                    ConditionMetFundModel(learningDelivery.FundModel) &&
                    (ConditionMetONSPostcode(latestLearningStart, onsPostcodesMatchinglocalEnterprisePartnerships) ||
                     ConditionMetPartnership(partnerships, onsPostCode)))
                {
                    HandleValidationError(
                        learner.LearnRefNumber,
                        learningDelivery.AimSeqNumber,
                        BuildErrorMessageParameters(learningDelivery));
                }
            }
        }
Exemple #2
0
        public void Validate(ILearner learner)
        {
            if (learner?.LearningDeliveries == null)
            {
                return;
            }

            foreach (var learningDelivery in learner.LearningDeliveries)
            {
                if (learningDelivery.LearnStartDate > _ruleEndDate)
                {
                    continue;
                }

                if (learningDelivery.FundModel != FundModel ||
                    learningDelivery.LearnAimRef.CaseInsensitiveEquals(TypeOfAim.References.ESFLearnerStartandAssessment) ||
                    learningDelivery.DelLocPostCode.CaseInsensitiveEquals(ValidationConstants.TemporaryPostCode))
                {
                    continue;
                }

                var partnerships = _fcsDataService.GetEligibilityRuleEnterprisePartnershipsFor(learningDelivery.ConRefNumber);
                if (partnerships == null || partnerships.All(la => string.IsNullOrEmpty(la.Code?.Trim())))
                {
                    continue;
                }

                var onsPostCodes = _postcodeService.GetONSPostcodes(learningDelivery.DelLocPostCode);
                if ((onsPostCodes?.Count ?? 0) == 0)
                {
                    continue;
                }

                DateTime?latestLearningStart =
                    _derivedData22.GetLatestLearningStartForESFContract(learningDelivery, learner.LearningDeliveries);
                if (!latestLearningStart.HasValue)
                {
                    continue;
                }

                if (PostcodesContainValidPostcode(latestLearningStart, onsPostCodes))
                {
                    continue;
                }

                if (partnerships.Any(
                        eli => onsPostCodes.Any(pc => (pc.Lep1.CaseInsensitiveEquals(eli.Code) || pc.Lep2.CaseInsensitiveEquals(eli.Code)) &&
                                                CheckQualifyingPeriod(latestLearningStart, pc))))
                {
                    HandleValidationError(
                        learner.LearnRefNumber,
                        learningDelivery.AimSeqNumber,
                        BuildErrorMessageParameters(learningDelivery));
                }
            }
        }