public void Validate(ILearner objectToValidate)
        {
            if (objectToValidate?.LearningDeliveries == null)
            {
                return;
            }

            if (objectToValidate.DateOfBirthNullable.HasValue)
            {
                var learnersSixteenthBirthdate = objectToValidate.DateOfBirthNullable.Value.AddYears(16);
                var firstAugustForAcademicYearOfLearnersSixteenthBirthDate = _academicYearQueryService.GetAcademicYearOfLearningDate(learnersSixteenthBirthdate, AcademicYearDates.TraineeshipsAugust1);

                foreach (var learningDelivery in objectToValidate.LearningDeliveries)
                {
                    if (ConditionMet(
                            learningDelivery,
                            firstAugustForAcademicYearOfLearnersSixteenthBirthDate))
                    {
                        HandleValidationError(
                            objectToValidate.LearnRefNumber,
                            learningDelivery.AimSeqNumber,
                            BuildErrorMessageParameters(objectToValidate.DateOfBirthNullable, learningDelivery.LearnStartDate));
                    }
                }
            }
        }
        public bool ConditionMetLearningDelivery(DateTime learnStartDate, DateTime?learnActDateNullable)
        {
            var result = false;

            if (learnActDateNullable.HasValue)
            {
                var learnStartDateAcademicYear = _academicYearQueryService.GetAcademicYearOfLearningDate(learnStartDate, AcademicYearDates.Commencement);
                var learnEndDateAcademicYear   = _academicYearQueryService.GetAcademicYearOfLearningDate(learnActDateNullable.Value, AcademicYearDates.Commencement);

                if (learnStartDate >= _dateCondition && learnStartDateAcademicYear.Year == learnEndDateAcademicYear.Year)
                {
                    result = true;
                }
            }

            return(result);
        }
コード例 #3
0
 public bool LearningDeliveryConditionMet(DateTime?dateOfBirth, DateTime learnStartDate)
 => dateOfBirth.HasValue &&
 learnStartDate >= _augustFirst2014 &&
 _dateTimeQueryService.YearsBetween(
     dateOfBirth.Value,
     _academicYearQueryService.GetAcademicYearOfLearningDate(
         learnStartDate,
         AcademicYearDates.August31)) >= 19;
コード例 #4
0
 public DateTime GetYearOfLearningCommencementDate(DateTime candidate) =>
 _yearData.GetAcademicYearOfLearningDate(candidate, AcademicYearDates.PreviousYearEnd);