Exemplo n.º 1
0
        public async Task Then_adds_if_new()
        {
            // Arrange
            var model     = _fixture.Create <LearnerModel>();
            var aggregate = _learnerFactory.CreateNew(model.Id, model.ApprenticeshipIncentiveId,
                                                      model.ApprenticeshipId, model.Ukprn, model.UniqueLearnerNumber);

            // Act
            await _sut.Save(aggregate);

            // Assert
            _learnerDataRepositoryMock.Verify(r => r.Add(aggregate.GetModel()), Times.Once);
        }
        public async Task Handle(CalculateDaysInLearningCommand command, CancellationToken cancellationToken = default)
        {
            var incentive = await _incentiveDomainRepository.Find(command.ApprenticeshipIncentiveId);

            if (incentive == null)
            {
                return;
            }

            Learner learner = await _learnerDomainRepository.Get(incentive);

            if (learner.SubmissionData.SubmissionFound)
            {
                var calendar = await _collectionCalendarService.Get();

                var collectionPeriod = calendar.GetPeriod(new Domain.ValueObjects.CollectionPeriod(command.CollectionPeriodNumber, command.CollectionYear));

                learner.SetDaysInLearning(collectionPeriod);
            }
            else
            {
                learner.ClearDaysInLearning();
            }

            await _learnerDomainRepository.Save(learner);
        }
Exemplo n.º 3
0
        public async Task Handle(RefreshLearnerCommand command, CancellationToken cancellationToken = default)
        {
            var incentive = await _incentiveDomainRepository.Find(command.ApprenticeshipIncentiveId);

            var learner = await _learnerDomainRepository.GetOrCreate(incentive);

            _logger.LogInformation("Start Learner data refresh from Learner match service for ApprenticeshipIncentiveId: {ApprenticeshipIncentiveId}, ApprenticeshipId: {ApprenticeshipId}, UKPRN: {UKPRN}, ULN: {ULN}",
                                   learner.ApprenticeshipIncentiveId, learner.ApprenticeshipId, learner.Ukprn, learner.UniqueLearnerNumber);

            SubmissionData submissionData = new SubmissionData();
            var            learnerData    = await _learnerService.Get(learner);

            _logger.LogInformation("End Learner data refresh from Learner match service for ApprenticeshipIncentiveId: {ApprenticeshipIncentiveId}, ApprenticeshipId: {ApprenticeshipId}, UKPRN: {UKPRN}, ULN: {ULN}",
                                   learner.ApprenticeshipIncentiveId, learner.ApprenticeshipId, learner.Ukprn, learner.UniqueLearnerNumber);

            if (learnerData != null)
            {
                if (LearnerAndEarningsHaveNotChanged(learnerData, learner, incentive))
                {
                    return;
                }

                submissionData.SetSubmissionDate(learnerData.IlrSubmissionDate);

                var learningFoundStatus = learnerData.LearningFound(incentive);
                submissionData.SetLearningData(new LearningData(learningFoundStatus.LearningFound, learningFoundStatus.NotFoundReason));

                if (learningFoundStatus.LearningFound)
                {
                    submissionData.LearningData.SetStartDate(learnerData.LearningStartDate(incentive));
                    submissionData.LearningData.SetHasDataLock(learnerData.HasProviderDataLocks(incentive));
                    submissionData.LearningData.SetIsInLearning(learnerData.IsInLearning(incentive));
                    submissionData.LearningData.SetIsStopped(learnerData.IsStopped(incentive));
                }
                submissionData.SetRawJson(learnerData.RawJson);
            }

            if (submissionData.HasChangeOfCircumstances(learner.SubmissionData))
            {
                incentive.SetHasPossibleChangeOfCircumstances(true);
            }

            learner.SetSubmissionData(submissionData);
            incentive.LearnerRefreshCompleted();

            learner.SetLearningPeriods(learnerData.LearningPeriods(incentive));

            if (!learner.SubmissionData.LearningData.LearningFound)
            {
                _logger.LogInformation("Matching ILR record not found for ApprenticeshipIncentiveId: {ApprenticeshipIncentiveId}, ApprenticeshipId: {ApprenticeshipId}, UKPRN: {UKPRN}, ULN: {ULN} with reason: {NotFoundReason}",
                                       learner.ApprenticeshipIncentiveId, learner.ApprenticeshipId, learner.Ukprn, learner.UniqueLearnerNumber, learner.SubmissionData.LearningData.NotFoundReason);
            }

            await _learnerDomainRepository.Save(learner);

            await _incentiveDomainRepository.Save(incentive);
        }
Exemplo n.º 4
0
        public async Task Handle(SetSuccessfulLearnerMatchCommand command, CancellationToken cancellationToken = default)
        {
            var incentive = await _incentiveDomainRepository.Find(command.ApprenticeshipIncentiveId);

            if (incentive == null)
            {
                return;
            }

            var learner = await _learnerDomainRepository.GetOrCreate(incentive);

            learner.SetSuccessfulLearnerMatch(command.Succeeded);

            await _learnerDomainRepository.Save(learner);
        }