Exemple #1
0
        public void Validate(ILearner learner)
        {
            if (learner?.LearningDeliveries == null)
            {
                return;
            }

            foreach (var learningDelivery in learner.LearningDeliveries)
            {
                if (ProgTypeConditionMet(learningDelivery.ProgTypeNullable))
                {
                    if (learningDelivery.LearningDeliveryFAMs == null)
                    {
                        continue;
                    }

                    foreach (var deliveryFam in _learningDeliveryFamQueryService.GetLearningDeliveryFAMsForType(learningDelivery.LearningDeliveryFAMs, LearningDeliveryFAMTypeConstants.SOF))
                    {
                        if (!_famCodes.Contains(deliveryFam.LearnDelFAMCode))
                        {
                            HandleValidationError(learner.LearnRefNumber, learningDelivery.AimSeqNumber, BuildErrorMessageParameters(learningDelivery.ProgTypeNullable, deliveryFam.LearnDelFAMCode));
                        }
                    }
                }
            }
        }
        public void Validate(ILearner objectToValidate)
        {
            if (objectToValidate.LearningDeliveries == null)
            {
                return;
            }

            foreach (var learningDelivery in objectToValidate.LearningDeliveries)
            {
                var learningDeliveryFAMs = _learningDeliveryFAMQueryService
                                           .GetLearningDeliveryFAMsForType(learningDelivery.LearningDeliveryFAMs, _famTypeACT).ToList();

                if (DoesNotHaveMultipleACTFams(learningDeliveryFAMs))
                {
                    return;
                }

                var invalidLearningDeliveryFAMs = LearningDeliveryFamForOverlappingACTTypes(learningDeliveryFAMs).ToList();

                if (invalidLearningDeliveryFAMs.Any())
                {
                    foreach (var learningDeliveryFAM in invalidLearningDeliveryFAMs)
                    {
                        HandleValidationError(
                            objectToValidate.LearnRefNumber,
                            learningDelivery.AimSeqNumber,
                            errorMessageParameters: BuildErrorMessageParameters(
                                _famTypeACT,
                                learningDeliveryFAM.LearnDelFAMDateFromNullable,
                                learningDeliveryFAM.LearnDelFAMDateToNullable));
                    }
                }
            }
        }
Exemple #3
0
        private ILearningDelivery GetLearningDeliveryWithLatestFAMDateFrom(IReadOnlyCollection <ILearningDelivery> learningDeliveries)
        {
            DateTime          latestACTFAMFrom = DateTime.MinValue;
            ILearningDelivery result           = null;

            foreach (var learningDelivery in learningDeliveries)
            {
                if (learningDelivery.LearningDeliveryFAMs != null)
                {
                    ILearningDeliveryFAM ldfamWithLatestDateFrom =
                        _learningDeliveryFAMQueryService.GetLearningDeliveryFAMsForType(learningDelivery.LearningDeliveryFAMs, LearningDeliveryFAMTypeConstants.ACT)
                        .Where(fam => fam.LearnDelFAMDateFromNullable.HasValue)
                        .OrderByDescending(f => f.LearnDelFAMDateFromNullable)
                        .FirstOrDefault();

                    if (ldfamWithLatestDateFrom != null &&
                        ldfamWithLatestDateFrom.LearnDelFAMDateFromNullable.HasValue &&
                        ldfamWithLatestDateFrom.LearnDelFAMDateFromNullable.Value > latestACTFAMFrom)
                    {
                        latestACTFAMFrom = ldfamWithLatestDateFrom.LearnDelFAMDateFromNullable.Value;
                        if (learningDelivery.LearnActEndDateNullable.HasValue)
                        {
                            result = learningDelivery;
                        }
                    }
                }
            }

            return(result);
        }
 private ILearningDeliveryFAM GetEligibleLearningDeliveryFam(IEnumerable <ILearningDeliveryFAM> learningDeliveryFams)
 {
     return(_learningDeliveryFAMQueryService.GetLearningDeliveryFAMsForType(learningDeliveryFams, LearningDeliveryFAMTypeConstants.ACT)
            .Where(fam => fam.LearnDelFAMDateFromNullable.HasValue)
            .OrderByDescending(f => f.LearnDelFAMDateFromNullable)
            .FirstOrDefault());
 }
        public void HandleErrors(string learnRefNumber, ILearningDelivery learningDelivery)
        {
            var sofDeliveryFams = _learningDeliveryFAMQueryService.GetLearningDeliveryFAMsForType(learningDelivery.LearningDeliveryFAMs, LearningDeliveryFAMTypeConstants.SOF);

            if (sofDeliveryFams.Any())
            {
                foreach (var learningDeliveryFAM in sofDeliveryFams)
                {
                    HandleValidationError(learnRefNumber, learningDelivery.AimSeqNumber, BuildErrorMessageParameters(learningDelivery.LearnStartDate, learningDeliveryFAM.LearnDelFAMCode));
                }

                return;
            }

            HandleValidationError(learnRefNumber, learningDelivery.AimSeqNumber, BuildErrorMessageParameters(learningDelivery.LearnStartDate, null));
        }
Exemple #6
0
        public void Validate(ILearner objectToValidate)
        {
            if (objectToValidate.LearningDeliveries == null)
            {
                return;
            }

            var ukprn            = _fileDataService.UKPRN();
            var longTermResUkprn = _organisationDataService.IsLongTermResForUkprn(ukprn);

            foreach (var learningDelivery in objectToValidate.LearningDeliveries)
            {
                var devolvedPostcodes = _postcodesDataService.GetDevolvedPostcodes(learningDelivery.LSDPostcode);
                var dd35 = _dd35.IsCombinedAuthorities(learningDelivery);

                foreach (var sofLdFams in _learningDeliveryFAMQueryService.GetLearningDeliveryFAMsForType(learningDelivery?.LearningDeliveryFAMs, LearningDeliveryFAMTypeConstants.SOF))
                {
                    if (
                        ConditionMet(
                            learningDelivery.LearnStartDate,
                            learningDelivery.FundModel,
                            learningDelivery.ProgTypeNullable,
                            learningDelivery.LSDPostcode,
                            devolvedPostcodes,
                            dd35,
                            sofLdFams.LearnDelFAMCode,
                            learningDelivery.LearningDeliveryFAMs,
                            longTermResUkprn))
                    {
                        HandleValidationError(
                            objectToValidate.LearnRefNumber,
                            learningDelivery.AimSeqNumber,
                            errorMessageParameters: BuildErrorMessageParameters(
                                learningDelivery.LearnStartDate,
                                learningDelivery.FundModel,
                                learningDelivery.LSDPostcode,
                                LearningDeliveryFAMTypeConstants.SOF,
                                sofLdFams.LearnDelFAMCode));
                    }
                }
            }
        }
Exemple #7
0
 public DateTime?GetLatestFAMDateTo(IEnumerable <ILearningDeliveryFAM> fromMonitors) =>
 _learningDeliveryFamQueryService.GetLearningDeliveryFAMsForType(fromMonitors, LearningDeliveryFAMTypeConstants.ACT)
 .OrderByDescending(x => x.LearnDelFAMDateFromNullable)
 .FirstOrDefault()?
 .LearnDelFAMDateToNullable;