public bool Evaluate(List <LearningDelivery> ObjectToValidate)
        {
            //get the Progstart date from dd04 for each LD
            var validStartProgDatesWithLDs = _dd04Rule.Evaluate(ObjectToValidate);

            var doB = ObjectToValidate.FirstOrDefault().DateOfBirth;

            var yearLearnerTurning16 = _dateHelper.GetYearInWhichPersonTurnsTo(16, doB);

            if (yearLearnerTurning16 == 0)
            {
                return(false);                           //Dob is null
            }
            var lastFridayInJuneInAcaYear = _dateHelper.GetLastFridayInJuneOfAcademicYear(new DateTime(yearLearnerTurning16,
                                                                                                       doB.Value.Month, doB.Value.Day));

            var apprenticeProgAllowedStartDate = Convert.ToDateTime(_ReferenceData.Get("ApprencticeProgAllowedStartDate"));

            foreach (var ld in validStartProgDatesWithLDs)
            {
                //if DD04 startdateofprog is less than allowedstart date then skip the ld
                if (ld.StartDateOfProgramme >= apprenticeProgAllowedStartDate &&
                    ld.StartDateOfProgramme <= lastFridayInJuneInAcaYear)
                {
                    return(true);
                }
            }



            return(false);
        }
Exemplo n.º 2
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 bool Validate(MessageLearner ObjectToValidate)
        {
            //check DoB rule, proceed only if the Dob is not null
            if (_learnerDoBNotNullRule.Evaluate(ObjectToValidate))
            {
                return(true);
            }

            //check agerule, if learner is above 16 then skip this rule
            if (_IsLearnerBelowSchoolAge.Evaluate(ObjectToValidate))
            {
                return(true);
            }

            //check the DD07 rule and get the valid prog type LDs
            ObjectToValidate.LearningDelivery = ObjectToValidate.LearningDelivery.Where(ld => !_dd07IsYRule.Evaluate(ld)).ToArray();

            //execute DD04 and fetch programme start date.
            if (_dd04IsInRangeRule.Evaluate(ObjectToValidate))
            {
                _validationErrorHandler.Handle(ObjectToValidate, RuleNameConstants.DateOfBirth_48);
                return(false);
            }

            return(true);
        }
        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);
        }
Exemplo n.º 5
0
        public ValidationResult Validate(Learner ObjectToValidate)
        {
            var result = new ValidationResult()
            {
                IsValid  = true,
                RuleName = "DateOfBirth_48"
            };


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

            //check agerule, if learner is above 16 then skip this rule
            if (_IsLearnerBelowSchoolAge.Evaluate(ObjectToValidate))
            {
                return(result);
            }

            //check the DD07 rule and get the valid prog type LDs
            var validProgTypeLDs = ObjectToValidate.LearningDeliveries.Where(ld => !_dd07IsYRule.Evaluate(ld)).ToList();


            //execute DD04 and fetch programme start date.
            if (_dd04IsInRangeRule.Evaluate(validProgTypeLDs))
            {
                result.IsValid       = false;
                result.ErrorMessages = new List <string>()
                {
                    _ErrorMessage
                };
                return(result);
            }

            return(result);
        }
 public bool Evaluate(Learner objectToValidate)
 {
     return(objectToValidate.LearningDeliveries.Any(ld => _dd07Rule.Evaluate(ld) == "Y"));
 }
 public bool Evaluate(LearningDelivery ObjectToValidate)
 {
     return(_dd07Rule.Evaluate(ObjectToValidate) != "Y");
 }
Exemplo n.º 8
0
 public bool Evaluate(Learner learner)
 {
     return(_dd21Rule.Evaluate(learner) == "Y");
 }