public async Task <DataLockMismatchViewModel> GetApprenticeshipMismatchDataLock(long providerId, string hashedApprenticeshipId) { var apprenticeshipId = _hashingService.DecodeValue(hashedApprenticeshipId); _logger.Info($"Getting apprenticeship datalock for provider: {providerId}", providerId: providerId, apprenticeshipId: apprenticeshipId); var datalockSummary = await _mediator.Send(new GetApprenticeshipDataLockSummaryQueryRequest { ProviderId = providerId, ApprenticeshipId = apprenticeshipId }); var data = await _mediator.Send(new GetApprenticeshipQueryRequest { ProviderId = providerId, ApprenticeshipId = apprenticeshipId }); var commitmentData = await _mediator.Send(new GetCommitmentQueryRequest { ProviderId = providerId, CommitmentId = data.Apprenticeship.CommitmentId }); var priceHistory = await _mediator.Send(new GetApprenticeshipPriceHistoryQueryRequest { ProviderId = providerId, ApprenticeshipId = apprenticeshipId }); var datalockSummaryViewModel = await _dataLockMapper.MapDataLockSummary(datalockSummary.DataLockSummary, data.Apprenticeship.HasHadDataLockSuccess); var dasRecordViewModel = _apprenticeshipMapper.MapApprenticeship(data.Apprenticeship, commitmentData.Commitment); var priceDataLocks = datalockSummaryViewModel .DataLockWithCourseMismatch .Concat(datalockSummaryViewModel.DataLockWithOnlyPriceMismatch) .Where(m => m.DataLockErrorCode.HasFlag(DataLockErrorCode.Dlock07)) .OrderBy(x => x.IlrEffectiveFromDate); return(new DataLockMismatchViewModel { ProviderId = providerId, HashedApprenticeshipId = hashedApprenticeshipId, DasApprenticeship = dasRecordViewModel, DataLockSummaryViewModel = datalockSummaryViewModel, EmployerName = data.Apprenticeship.LegalEntityName, PriceDataLocks = _dataLockMapper.MapPriceDataLock(priceHistory.History, priceDataLocks), CourseDataLocks = _dataLockMapper.MapCourseDataLock(dasRecordViewModel, datalockSummaryViewModel.DataLockWithCourseMismatch, data.Apprenticeship, priceHistory.History) }); }
public async Task <ExtendedApprenticeshipViewModel> GetApprenticeship(long providerId, string hashedCommitmentId, string hashedApprenticeshipId) { var apprenticeshipId = HashingService.DecodeValue(hashedApprenticeshipId); var commitmentId = HashingService.DecodeValue(hashedCommitmentId); Logger.Info($"Getting apprenticeship:{apprenticeshipId} for provider:{providerId}", providerId: providerId, commitmentId: commitmentId, apprenticeshipId: apprenticeshipId); var data = await Mediator.Send(new GetApprenticeshipQueryRequest { ProviderId = providerId, ApprenticeshipId = apprenticeshipId }); var commitment = await GetCommitment(providerId, commitmentId); AssertCommitmentStatus(commitment); var overlappingErrors = await Mediator.Send( new GetOverlappingApprenticeshipsQueryRequest { Apprenticeship = new List <Apprenticeship> { data.Apprenticeship } }); var apprenticeship = _apprenticeshipMapper.MapApprenticeship(data.Apprenticeship, commitment); apprenticeship.ProviderId = providerId; return(new ExtendedApprenticeshipViewModel { Apprenticeship = apprenticeship, ApprenticeshipProgrammes = await GetTrainingProgrammes(!commitment.IsTransfer()), ValidationErrors = _apprenticeshipCoreValidator.MapOverlappingErrors(overlappingErrors) }); }