public async Task <ApprenticeshipViewModel> GetApprenticeship(string hashId, string accountHashedId) { _logger.Trace("Retrieving Apprenticeship Details"); var apprenticeshipId = _hashingService.DecodeValue(hashId); var accountId = _hashingService.DecodeValue(accountHashedId); var response = await _mediator.SendAsync(new GetApprenticeshipRequest { Caller = new Caller { Id = accountId, CallerType = CallerType.Support }, ApprenticeshipId = apprenticeshipId }); if (response.Data == null) { var errorMsg = $"Can't find Apprenticeship with Hash Id {hashId}"; _logger.Warn(errorMsg); throw new Exception(errorMsg); } return(_apprenticeshipMapper.MapToApprenticeshipViewModel(response.Data)); }
public async Task <OrchestratorResponse <ExtendedApprenticeshipViewModel> > GetApprenticeshipForEdit( string hashedAccountId, string hashedApprenticeshipId, string externalUserId) { var accountId = _hashingService.DecodeValue(hashedAccountId); var apprenticeshipId = _hashingService.DecodeValue(hashedApprenticeshipId); _logger.Info( $"Getting Approved Apprenticeship for Editing, Account: {accountId}, ApprenticeshipId: {apprenticeshipId}"); return(await CheckUserAuthorization(async() => { await AssertApprenticeshipStatus(accountId, apprenticeshipId); // TODO: LWA Assert that the apprenticeship can be edited - Story says should be allowed to go to edit details page?? var data = await _mediator.SendAsync(new GetApprenticeshipQueryRequest { AccountId = accountId, ApprenticeshipId = apprenticeshipId }); AssertApprenticeshipIsEditable(data.Apprenticeship); var apprenticeship = _apprenticeshipMapper.MapToApprenticeshipViewModel(data.Apprenticeship); apprenticeship.HashedAccountId = hashedAccountId; return new OrchestratorResponse <ExtendedApprenticeshipViewModel> { Data = new ExtendedApprenticeshipViewModel { Apprenticeship = apprenticeship, ApprenticeshipProgrammes = await GetTrainingProgrammes(), } }; }, hashedAccountId, externalUserId)); }
public async Task <OrchestratorResponse <ExtendedApprenticeshipViewModel> > GetApprenticeshipForEdit( string hashedAccountId, string hashedApprenticeshipId, string externalUserId) { var accountId = HashingService.DecodeValue(hashedAccountId); var apprenticeshipId = HashingService.DecodeValue(hashedApprenticeshipId); Logger.Info($"Getting Approved Apprenticeship for Editing, Account: {accountId}, ApprenticeshipId: {apprenticeshipId}"); return(await CheckUserAuthorization(async() => { await AssertApprenticeshipStatus(accountId, apprenticeshipId); //todo: whenall var apprenticeshipData = await Mediator.SendAsync(new GetApprenticeshipQueryRequest { AccountId = accountId, ApprenticeshipId = apprenticeshipId }); var commitmentData = await Mediator.SendAsync(new GetCommitmentQueryRequest { AccountId = accountId, CommitmentId = apprenticeshipData.Apprenticeship.CommitmentId }); AssertApprenticeshipIsEditable(apprenticeshipData.Apprenticeship); var apprenticeship = _apprenticeshipMapper.MapToApprenticeshipViewModel(apprenticeshipData.Apprenticeship, commitmentData.Commitment); apprenticeship.HashedAccountId = hashedAccountId; var includeFrameworks = commitmentData.Commitment.ApprenticeshipEmployerTypeOnApproval != ApprenticeshipEmployerType.NonLevy; return new OrchestratorResponse <ExtendedApprenticeshipViewModel> { Data = new ExtendedApprenticeshipViewModel { Apprenticeship = apprenticeship, ApprenticeshipProgrammes = await GetTrainingProgrammes(includeFrameworks) } }; }, hashedAccountId, externalUserId)); }