Esempio n. 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);

                if (ConditionMetDD22Exists(latestLearningStart) &&
                    ConditionMetStartDate(learningDelivery.LearnStartDate) &&
                    ConditionMetFundModel(learningDelivery.FundModel) &&
                    ConditionMetLearnAimRef(learningDelivery.LearnAimRef) &&
                    ConditionMetTemporaryPostcode(learningDelivery.DelLocPostCode) &&
                    (ConditionMetONSPostcode(latestLearningStart, onsPostCode) ||
                     ConditionMetPartnership(partnerships, onsPostCode)))
                {
                    HandleValidationError(
                        learner.LearnRefNumber,
                        learningDelivery.AimSeqNumber,
                        BuildErrorMessageParameters(learningDelivery));
                }
            }
        }
Esempio n. 2
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 localAuthorities = _fcsDataService.GetEligibilityRuleLocalAuthoritiesFor(learningDelivery.ConRefNumber);

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

                var allOnsPostCodes = _postcodeService.GetONSPostcodes(learningDelivery.DelLocPostCode);
                var onsPostcodesMatchinglocalAuthorities = allOnsPostCodes.Where(pc => localAuthorities.Any(la => la.Code.CaseInsensitiveEquals(pc.LocalAuthority)));

                if (ConditionMetDD22Exists(latestLearningStart) &&
                    ConditionMetStartDate(learningDelivery.LearnStartDate) &&
                    ConditionMetFundModel(learningDelivery.FundModel) &&
                    (ConditionMetONSPostcode(latestLearningStart, onsPostcodesMatchinglocalAuthorities) ||
                     ConditionMetLocalAuthority(localAuthorities, allOnsPostCodes)))
                {
                    HandleValidationError(
                        learner.LearnRefNumber,
                        learningDelivery.AimSeqNumber,
                        BuildErrorMessageParameters(learningDelivery));
                }
            }
        }
Esempio n. 3
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));
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Gets the ons postcode.
 /// </summary>
 /// <param name="delivery">The delivery.</param>
 /// <returns>the ons postcodes (if found)</returns>
 public IReadOnlyCollection <IONSPostcode> GetONSPostcodes(ILearningDelivery delivery) =>
 _postcodesData.GetONSPostcodes(delivery.DelLocPostCode);