示例#1
0
        private async Task <bool> HandleEnglishAndMathsChanges(UpdateLearnerRecordRequest request)
        {
            var profile = await _tqRegistrationProfile.GetFirstOrDefaultAsync(p => p.Id == request.ProfileId && p.UniqueLearnerNumber == request.Uln &&
                                                                              p.IsEnglishAndMathsAchieved.HasValue && p.IsRcFeed == true &&
                                                                              p.TqRegistrationPathways.Any(pa => pa.TqProvider.TlProvider.UkPrn == request.Ukprn &&
                                                                                                           (pa.Status == RegistrationPathwayStatus.Active || pa.Status == RegistrationPathwayStatus.Withdrawn)));

            if (profile == null)
            {
                _logger.LogWarning(LogEvent.NoDataFound, $"No record found to update English and Maths for Uln = {request.Uln}. Method: HandleEnglishAndMathsChanges({request})");
                return(false);
            }

            _mapper.Map(request, profile);
            return(await _tqRegistrationProfile.UpdateWithSpecifedColumnsOnlyAsync(profile, p => p.IsEnglishAndMathsAchieved, p => p.IsSendLearner, p => p.ModifiedOn, p => p.ModifiedBy) > 0);
        }
示例#2
0
        private async Task <bool> HandleIndustryPlacementChanges(UpdateLearnerRecordRequest request)
        {
            var industryPlacement = await _industryPlacementRepository.GetFirstOrDefaultAsync(ip => ip.Id == request.IndustryPlacementId &&
                                                                                              ip.TqRegistrationPathway.Id == request.RegistrationPathwayId &&
                                                                                              ip.TqRegistrationPathway.TqRegistrationProfileId == request.ProfileId &&
                                                                                              ip.TqRegistrationPathway.TqProvider.TlProvider.UkPrn == request.Ukprn &&
                                                                                              (ip.TqRegistrationPathway.Status == RegistrationPathwayStatus.Active ||
                                                                                               ip.TqRegistrationPathway.Status == RegistrationPathwayStatus.Withdrawn));

            if (industryPlacement == null)
            {
                _logger.LogWarning(LogEvent.NoDataFound, $"No record found to update Industry Placement for Uln = {request.Uln}. Method: HandleIndustryPlacementChanges({request})");
                return(false);
            }

            _mapper.Map(request, industryPlacement);
            return(await _industryPlacementRepository.UpdateWithSpecifedColumnsOnlyAsync(industryPlacement, ip => ip.Status, ip => ip.ModifiedOn, ip => ip.ModifiedBy) > 0);
        }
示例#3
0
        public async Task <bool> UpdateLearnerRecordAsync(UpdateLearnerRecordRequest request)
        {
            if (request == null || (!request.HasEnglishAndMathsChanged && !request.HasIndustryPlacementChanged))
            {
                _logger.LogWarning(LogEvent.NoDataFound, $"Model is null or no changes detected to update Learner record for Uln = {request.Uln}. Method: UpdateLearnerRecordAsync({request})");
                return(false);
            }

            bool isSuccess = false;

            if (request.HasEnglishAndMathsChanged)
            {
                isSuccess = await HandleEnglishAndMathsChanges(request);
            }
            else if (request.HasIndustryPlacementChanged)
            {
                isSuccess = await HandleIndustryPlacementChanges(request);
            }

            return(isSuccess);
        }
        public override void Setup()
        {
            _tokenServiceClient = Substitute.For <ITokenServiceClient>();

            _configuration = new ResultsAndCertificationConfiguration
            {
                ResultsAndCertificationInternalApiSettings = new ResultsAndCertificationInternalApiSettings {
                    Uri = "http://tlevel.api.com"
                }
            };

            _mockHttpResult = true;

            _model = new UpdateLearnerRecordRequest
            {
                Ukprn                       = 58974561,
                ProfileId                   = 1,
                RegistrationPathwayId       = 7,
                IndustryPlacementId         = 1,
                IndustryPlacementStatus     = IndustryPlacementStatus.CompletedWithSpecialConsideration,
                HasIndustryPlacementChanged = true,
                PerformedBy                 = "Test User"
            };
        }
示例#5
0
 public async Task <bool> UpdateLearnerRecordAsync(UpdateLearnerRecordRequest model)
 {
     return(await _trainingProviderService.UpdateLearnerRecordAsync(model));
 }
 public async Task <bool> UpdateLearnerRecordAsync(UpdateLearnerRecordRequest model)
 {
     return(await PutAsync <UpdateLearnerRecordRequest, bool>(ApiConstants.UpdateLearnerRecordUri, model));
 }