public void Validate(ILearner objectToValidate)
        {
            if (LearnerNullConditionMet(objectToValidate.DateOfBirthNullable))
            {
                foreach (var learningDelivery in objectToValidate.LearningDeliveries)
                {
                    var dd04 = _dd04.Derive(objectToValidate.LearningDeliveries, learningDelivery);

                    if (LearningDeliveryNullConditionMet(dd04, learningDelivery.LearnStartDateNullable) &&
                        DD04ConditionMet(dd04.Value) &&
                        DD07ConditionMet(_dd07.Derive(learningDelivery.ProgTypeNullable)) &&
                        DateOfBirthLearnStartDateConditionMet(objectToValidate.DateOfBirthNullable.Value, learningDelivery.LearnStartDateNullable.Value))
                    {
                        HandleValidationError(RuleNameConstants.DateOfBirth_10, objectToValidate.LearnRefNumber, learningDelivery.AimSeqNumberNullable);
                    }
                }
            }
        }
        public void Validate(ILearner objectToValidate)
        {
            if (!LearnerConditionMet(objectToValidate.DateOfBirthNullable))
            {
                return;
            }

            var sixteenthBirthday = BirthdayAt(objectToValidate.DateOfBirthNullable, 16);
            var lastFridayJuneAcademicYearLearnerSixteen = _academicYearCalendarService.LastFridayInJuneForDateInAcademicYear(sixteenthBirthday.Value);

            foreach (var learningDelivery in objectToValidate.LearningDeliveries.Where(ld => !Exclude(ld.ProgTypeNullable)))
            {
                if (DD07ConditionMet(_dd07.Derive(learningDelivery.ProgTypeNullable)) &&
                    DD04ConditionMet(_dd04.Derive(objectToValidate.LearningDeliveries, learningDelivery), _validationDataService.ApprencticeProgAllowedStartDate, lastFridayJuneAcademicYearLearnerSixteen))
                {
                    HandleValidationError(RuleNameConstants.DateOfBirth_48, objectToValidate.LearnRefNumber, learningDelivery.AimSeqNumberNullable);
                }
            }
        }
Пример #3
0
 public bool Exclude(ILearningDelivery learningDelivery)
 {
     return(HasLearningDeliveryDd07ExcludeConditionMet(_dd07.Derive(learningDelivery.ProgTypeNullable)) ||
            HasLearningDeliveryFundModelExcludeConditionMet(learningDelivery.FundModelNullable));
 }
 public void Validate(ILearner objectToValidate)
 {
     foreach (var learningDelivery in objectToValidate.LearningDeliveries)
     {
         if (ConditionMet(learningDelivery.LearnStartDate, _validationDataService.AcademicYearEnd, learningDelivery.ProgTypeNullable, _dd07.Derive(learningDelivery.ProgTypeNullable)))
         {
             HandleValidationError(RuleNameConstants.LearnStartDate_03, objectToValidate.LearnRefNumber, learningDelivery.AimSeqNumber);
         }
     }
 }