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)); } } }
public void Validate(ILearner objectToValidate) { if (objectToValidate?.LearningDeliveries == null || !objectToValidate.DateOfBirthNullable.HasValue) { return; } var sixteenthBirthDate = objectToValidate.DateOfBirthNullable.Value.AddYears(16); var lastFridayInJuneForAcademicYear = _academicYearQueryService.LastFridayInJuneForDateInAcademicYear(sixteenthBirthDate); foreach (var learningDelivery in objectToValidate.LearningDeliveries) { DateTime?dd18Date = _derivedData18.GetApprenticeshipStandardProgrammeStartDateFor(learningDelivery, objectToValidate.LearningDeliveries); if (ConditionMet( learningDelivery.ProgTypeNullable, dd18Date, lastFridayInJuneForAcademicYear)) { HandleValidationError(objectToValidate.LearnRefNumber, learningDelivery.AimSeqNumber); } } }