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); } } }
public void Validate(ILearner objectToValidate) { if (objectToValidate.LearningDeliveries == null || LearnerConditionMet(objectToValidate.DateOfBirthNullable)) { return; } foreach (var learningDelivery in objectToValidate.LearningDeliveries) { DateTime?dd04Date = _dd04.Derive(objectToValidate.LearningDeliveries, learningDelivery); DateTime sixteenthBirthDate = _datetimeQueryService.DateAddYears((DateTime)objectToValidate.DateOfBirthNullable, 16); DateTime lastFridayInJuneForAcademicYear = _academicYearQueryService.LastFridayInJuneForDateInAcademicYear(sixteenthBirthDate); if (ConditionMet(learningDelivery.ProgTypeNullable, dd04Date, lastFridayInJuneForAcademicYear)) { HandleValidationError(objectToValidate.LearnRefNumber, learningDelivery.AimSeqNumber, BuildErrorMessageParameters(objectToValidate.DateOfBirthNullable, learningDelivery.LearnStartDate)); } } }