/// <summary> /// Validates the specified object. /// </summary> /// <param name="learner">The object to validate.</param> public void Validate(ILearner learner) { if (learner?.DateOfBirthNullable == null || learner.LearnerFAMs == null || learner.LearningDeliveries == null) { return; } var age = _dateTimeQueryService.AgeAtGivenDate( learner.DateOfBirthNullable ?? DateTime.MinValue, _academicYearDataService.AugustThirtyFirst()); if (age < MinAge || age > MaxAge) { return; } if (learner.LearnerFAMs.All(lf => !lf.LearnFAMType.CaseInsensitiveEquals(LearnerFAMTypeConstants.HNS)) || learner.LearnerFAMs.Any(lf => lf.LearnFAMType.CaseInsensitiveEquals(LearnerFAMTypeConstants.EHC))) { return; } foreach (var learningDelivery in learner.LearningDeliveries) { if (learningDelivery.FundModel == TypeOfFunding.Age16To19ExcludingApprenticeships) { RaiseValidationMessage(learner, learningDelivery); } } }
/// <summary> /// Validates the specified object. /// </summary> /// <param name="learner">The object to validate.</param> public void Validate(ILearner learner) { if (learner?.LearningDeliveries == null || !learner.DateOfBirthNullable.HasValue) { return; } foreach (var learningDelivery in learner.LearningDeliveries) { if (learningDelivery.LearnStartDate > _ruleEndDate) { continue; } var age = _dateTimeQueryService.AgeAtGivenDate( learner.DateOfBirthNullable.Value, learningDelivery.LearnStartDate); if (age < MinAge) { continue; } if (_fundModels.All(fm => fm != learningDelivery.FundModel) || (learningDelivery.ProgTypeNullable ?? -1) != ProgrammeType || learningDelivery.AimType != AimType) { continue; } if (_learningDeliveryFAMQueryService.HasLearningDeliveryFAMType( learningDelivery.LearningDeliveryFAMs, LearningDeliveryFAMTypeConstants.RES)) { continue; } if (!learningDelivery.OutcomeNullable.HasValue || learningDelivery.OutcomeNullable.Value != OutcomeConstants.Achieved) { continue; } if (!learningDelivery.LearnActEndDateNullable.HasValue || _dateTimeQueryService.YearsBetween( learningDelivery.LearnStartDate, learningDelivery.LearnActEndDateNullable.Value) >= 1) { continue; } RaiseValidationMessage(learner, learningDelivery); } }
/// <summary> /// Validates the specified object. /// </summary> /// <param name="learner">The object to validate.</param> public void Validate(ILearner learner) { if (learner?.LearningDeliveries == null) { return; } if (!_priorAttain.Contains(learner.PriorAttainNullable ?? -1)) { return; } foreach (var learningDelivery in learner.LearningDeliveries) { if (learningDelivery.FundModel != FundingModel || learningDelivery.LearnStartDate <= _startDate || learningDelivery.LearningDeliveryFAMs == null) { continue; } var ageAtCourseStart = _dateTimeQueryService.AgeAtGivenDate(learner.DateOfBirthNullable ?? DateTime.MinValue, learningDelivery.LearnStartDate); if (ageAtCourseStart < MinAge || ageAtCourseStart > MaxAge) { continue; } var nvqLevel = _larsDataService.GetNotionalNVQLevelv2ForLearnAimRef(learningDelivery.LearnAimRef); if (!_nvqLevels.Any(x => x.CaseInsensitiveEquals(nvqLevel))) { continue; } if (ExclusionsApply(learner, learningDelivery)) { continue; } foreach (var deliveryFam in learningDelivery.LearningDeliveryFAMs) { if (deliveryFam.LearnDelFAMType.CaseInsensitiveEquals(LearningDeliveryFAMTypeConstants.FFI) && deliveryFam.LearnDelFAMCode.CaseInsensitiveEquals(InvalidFamCode)) { RaiseValidationMessage(learner, learningDelivery, deliveryFam); } } } }
public bool AgeConditionMet(DateTime learnStartDate, DateTime?dateOfBirth) { if (!dateOfBirth.HasValue) { return(false); } var ageAtCourseStart = _dateTimeQueryService.AgeAtGivenDate(dateOfBirth.Value, learnStartDate); if (ageAtCourseStart >= MinAge && ageAtCourseStart <= MaxAge) { return(true); } return(false); }
public int?GetLearnersAgeAtStartOfESFContract( ILearner learner, string conRefNumber) { if (learner?.DateOfBirthNullable == null) { return(null); } var delivery = learner.LearningDeliveries ?.OrderByDescending(x => x.LearnStartDate) .FirstOrDefault(ld => ld.LearnAimRef.CaseInsensitiveEquals(TypeOfAim.References.ESFLearnerStartandAssessment) && ld.CompStatus == CompletionState.HasCompleted && ld.ConRefNumber.CaseInsensitiveEquals(conRefNumber)); if (delivery == null) { return(null); } return(_dateTimeQueryService.AgeAtGivenDate( learner.DateOfBirthNullable.Value, delivery.LearnStartDate)); }
private bool ExceptionApplies(DateTime?dateOfBirth, IEnumerable <ILearningDelivery> learningDeliveries) { var startDate = _derivedData06.Derive(learningDeliveries); return(_dateTimeQueryService.AgeAtGivenDate(dateOfBirth ?? DateTime.MaxValue, startDate) >= MaxRuleAge); }
public bool DateOfBirthConditionMet(DateTime?dateOfBirth, DateTime learnStartDate) { return(dateOfBirth.HasValue && _dateTimeQueryService.AgeAtGivenDate(dateOfBirth.Value, learnStartDate) >= 24); }