/// <summary> /// Validates this learner. /// </summary> /// <param name="thisLearner">this learner.</param> public void Validate(ILearner thisLearner) { It.IsNull(thisLearner) .AsGuard <ArgumentNullException>(nameof(thisLearner)); var learnRefNumber = thisLearner.LearnRefNumber; IBranchResult expected = null; thisLearner.LearningDeliveries .ForAny(x => IsNotValid(x, expected = _actionProvider.GetBranchingResultFor(x, thisLearner)), x => RaiseValidationMessage(learnRefNumber, x, expected)); }
/// <summary> /// Passes the (rule) conditions. /// </summary> /// <param name="delivery">The delivery.</param> /// <param name="branch">The branch result.</param> /// <returns> /// true if it does... /// </returns> public override bool PassesConditions(ILearningDelivery delivery, IBranchResult branch) { /* * Where the learning aim validity criteria has been met in Table 1, * the record with the latest validity start date in the LARS database for this Learning aim reference * must have a validity end date (if entered) on or after the beginning of the current teaching year * * And in ’structured’ English: * * for the latest LARS_Validity (max LARS_Validity_StartDate) matching the LearningDelivery_LearnAimRef * if LARS_Validity_EndDate != null * and LARS_Validity_EndDate >= CommencementDateOfCurrentAcademicYear (i.e. 2018-08-01) * return OK * otherwise return error */ return(branch.OutOfScope || HasValidLearningAim(delivery, branch.Category)); }
/// <summary> /// Passes the (rule) conditions. /// </summary> /// <param name="delivery">The delivery.</param> /// <param name="branch">The branch result.</param> /// <returns> /// true if it does... /// </returns> public override bool PassesConditions(ILearningDelivery delivery, IBranchResult branch) { return(branch.OutOfScope || HasValidLearningAim(delivery, branch.Category)); }
/// <summary> /// Raises the validation message. /// </summary> /// <param name="learnRefNumber">The learn reference number.</param> /// <param name="thisDelivery">this delivery.</param> /// <param name="expected">The expected category.</param> public void RaiseValidationMessage(string learnRefNumber, ILearningDelivery thisDelivery, IBranchResult expected) { HandleValidationError(learnRefNumber, thisDelivery.AimSeqNumber, BuildMessageParametersFor(thisDelivery, expected)); }
/// <summary> /// Determines whether [is not valid] [the specified delivery]. /// </summary> /// <param name="delivery">The delivery.</param> /// <param name="branchResult">The branch result.</param> /// <returns> /// <c>true</c> if [is not valid] [the specified delivery]; otherwise, <c>false</c>. /// </returns> public bool IsNotValid(ILearningDelivery delivery, IBranchResult branchResult) => !PassesConditions(delivery, branchResult);
/// <summary> /// Passes the (rule) conditions. /// </summary> /// <param name="delivery">The delivery.</param> /// <param name="branchCategory">The branch category.</param> /// <returns> /// true if it does... /// </returns> public abstract bool PassesConditions(ILearningDelivery delivery, IBranchResult branchCategory);
/// <summary> /// Builds the message parameters for. /// </summary> /// <param name="thisDelivery">this delivery.</param> /// <param name="andExpected">and expected category.</param> /// <returns> /// a collection of message parameters /// </returns> public IEnumerable <IErrorMessageParameter> BuildMessageParametersFor(ILearningDelivery thisDelivery, IBranchResult andExpected) { return(new[] { BuildErrorMessageParameter(PropertyNameConstants.LearnAimRef, thisDelivery.LearnAimRef), BuildErrorMessageParameter("Expected Category", andExpected.Category) }); }
/// <summary> /// Passes the (rule) conditions. /// </summary> /// <param name="delivery">The delivery.</param> /// <param name="branch">The branch.</param> /// <returns> /// true if it does... /// </returns> public override bool PassesConditions(ILearningDelivery delivery, IBranchResult branch) { return(branch.OutOfScope || _isSetToPass); }