Ejemplo n.º 1
0
        public void Validate(MessageLearner learner)
        {
            // check exclusion rules first, if any exclusion rule is returning true then skip this rule.
            if (_learnerDelFamExclusionRulesValidator.Evaluate(learner))
            {
                return;
            }

            //check DoB rule, proceed only if the Dob is not null
            if (_learnerDoBShouldNotbeNull.Evaluate(learner))
            {
                return;
            }

            //fetch fundmodel 35 LDs for this academic year .
            var eligibleLDs = _fetchSpecificFundModelsLDsWithLearnStartDate.Evaluate(learner);

            if (eligibleLDs.LearningDelivery.Count() == 0)
            {
                return;
            }

            //check the learner age is 24 or more rule & LFAMType FAMCODE
            var validLDsWithCorrectAgeandFAMtypesAndLars = _pickValidLdsWithAgeLimitFamTypeAndCode.Evaluate(eligibleLDs);

            if (validLDsWithCorrectAgeandFAMtypesAndLars == null ||
                validLDsWithCorrectAgeandFAMtypesAndLars.Count == 0)
            {
                return;
            }

            _validationErrorHandler.Handle(learner, RuleNameConstants.LearnDelFam66);
        }
        public ValidationResult Validate(Learner learner)
        {
            var result = new ValidationResult()
            {
                IsValid  = true,
                RuleName = RuleNames.LearnDelFam66.ToString()
            };

            // check exclusion rules first, if any exclusion rule is returning true then skip this rule.
            if (_learnerDelFamExclusionRulesValidator.Evaluate(learner))
            {
                return(result);
            }

            //check DoB rule, proceed only if the Dob is not null
            if (_learnerDoBShouldNotbeNull.Evaluate(learner))
            {
                return(result);
            }


            //fetch fundmodel 35 LDs for this academic year .
            var eligibleLDs = _fetchSpecificFundModelsLDsWithLearnStartDate.Evaluate(learner);

            if (eligibleLDs.Count() == 0)
            {
                return(result);
            }

            //check the learner age is 24 or more rule & LFAMType FAMCODE
            var validLDsWithCorrectAgeandFAMtypesAndLars = _pickValidLdsWithAgeLimitFamTypeAndCode.Evaluate(eligibleLDs);

            if (validLDsWithCorrectAgeandFAMtypesAndLars == null ||
                validLDsWithCorrectAgeandFAMtypesAndLars.Count == 0)
            {
                return(result);
            }

            result.IsValid       = false;
            result.ErrorMessages = new List <String>()
            {
                ErrorMessage
            };

            return(result);
        }