public async Task <GetConfirmEmployerQueryResult> Handle(GetConfirmEmployerQuery request, CancellationToken cancellationToken) { var apprenticeshipTask = _commitmentsV2ApiClient.Get <GetApprenticeshipResponse>(new GetApprenticeshipRequest(request.ApprenticeshipId)); var accountLegalEntityTask = _commitmentsV2ApiClient.Get <GetAccountLegalEntityResponse>(new GetAccountLegalEntityRequest(request.AccountLegalEntityId)); await Task.WhenAll(apprenticeshipTask, accountLegalEntityTask); var apprenticeship = apprenticeshipTask.Result; var accountLegalEntity = accountLegalEntityTask.Result; var isFlexiJobAgency = await IsLegalEntityOnFjaaRegister(accountLegalEntity.MaLegalEntityId); if (apprenticeship == null || apprenticeship.ProviderId != request.ProviderId) { return(null); } return(new GetConfirmEmployerQueryResult { AccountLegalEntityName = accountLegalEntity.LegalEntityName, AccountName = accountLegalEntity.AccountName, LegalEntityName = apprenticeship.EmployerName, IsFlexiJobAgency = isFlexiJobAgency, DeliveryModel = apprenticeship.DeliveryModel }); }
public async Task <GetApprenticeshipsQueryResult> Handle(GetApprenticeshipsQuery request, CancellationToken cancellationToken) { var courses = await _courseLookupService.GetAllCourses(); var apiRequest = new GetApprenticeshipsRequest(request.AccountId, request.Status, request.PageNumber, request.PageItemCount); var response = await _commitmentsV2Api.Get <GetApprenticeshipsResponse>(apiRequest); return(new GetApprenticeshipsQueryResult { TotalApprenticeshipsFound = response.TotalApprenticeshipsFound, Apprenticeships = response.Apprenticeships.Select(a => new GetApprenticeshipsQueryResult.Apprenticeship { Id = a.Id, TransferSenderId = a.TransferSenderId, Uln = a.Uln, ProviderId = a.ProviderId, ProviderName = a.ProviderName, FirstName = a.FirstName, LastName = a.LastName, CourseCode = a.CourseCode, CourseName = a.CourseName, CourseLevel = courses.FirstOrDefault(x => x.Id == a.CourseCode)?.Level ?? 0, StartDate = a.StartDate, EndDate = a.EndDate, Cost = a.Cost, PledgeApplicationId = a.PledgeApplicationId, HasHadDataLockSuccess = a.HasHadDataLockSuccess }) }); }
public async Task <GetCohortResult> Handle(GetCohortQuery request, CancellationToken cancellationToken) { var cohort = await _commitmentsV2ApiClient.Get <GetCohortResponse>(new GetCohortRequest(request.CohortId)); return(new GetCohortResult { Cohort = cohort }); }
public async Task <GetAccountIdsQueryResult> Handle(GetAccountIdsQuery request, CancellationToken cancellationToken) { var result = await _commitmentsV2Api.Get <GetAccountsWithCohortsResponse>(new GetAccountsWithCohortsRequest()); return(new GetAccountIdsQueryResult { AccountIds = result.AccountIds }); }
public async Task <GetCohortResult> Handle(GetCohortQuery request, CancellationToken cancellationToken) { var result = await _apiClient.Get <GetCohortResponse>(new GetCohortRequest(request.CohortId)); if (result == null) { return(null); } return((GetCohortResult)result); }
public async Task <GetAccountLegalEntityQueryResult> Handle(GetAccountLegalEntityQuery request, CancellationToken cancellationToken) { var result = await _apiClient.Get <GetAccountLegalEntityResponse>(new GetAccountLegalEntityRequest(request.AccountLegalEntityId)); if (result == null) { return(null); } return((GetAccountLegalEntityQueryResult)result); }
public async Task <GetApplicationResult> Handle(GetApplicationQuery request, CancellationToken cancellationToken) { var application = await _levyTransferMatchingService.GetApplication(new GetApplicationRequest(request.ApplicationId)); if (application == null) { return(null); } var allJobRolesTask = _referenceDataService.GetJobRoles(); var allLevelsTask = _referenceDataService.GetLevels(); var allSectorsTask = _referenceDataService.GetSectors(); var pledgeTask = _levyTransferMatchingService.GetPledge(application.PledgeId); var cohortTask = _commitmentsV2ApiClient.Get <GetCohortsResponse>(new GetCohortsRequest { AccountId = request.AccountId }); await Task.WhenAll(allJobRolesTask, allLevelsTask, allSectorsTask, pledgeTask, cohortTask); var IsWithdrawableAfterAcceptance = !cohortTask.Result.Cohorts.Any(x => x.PledgeApplicationId.HasValue && x.PledgeApplicationId == request.ApplicationId) && application.NumberOfApprenticesUsed == 0; return(new GetApplicationResult { StandardTitle = application.StandardTitle, StandardLevel = application.StandardLevel, StandardDuration = application.StandardDuration, StandardMaxFunding = application.StandardMaxFunding, AllJobRoles = allJobRolesTask.Result, AllLevels = allLevelsTask.Result, AllSectors = allSectorsTask.Result, Amount = application.TotalAmount, TotalAmount = application.TotalAmount, EmployerAccountName = application.EmployerAccountName, PledgeEmployerAccountName = pledgeTask.Result.DasAccountName, IsNamePublic = pledgeTask.Result.IsNamePublic, JobRoles = pledgeTask.Result.JobRoles, Levels = pledgeTask.Result.Levels, PledgeLocations = pledgeTask.Result.Locations.Select(x => x.Name), NumberOfApprentices = application.NumberOfApprentices, RemainingAmount = pledgeTask.Result.RemainingAmount, Sectors = pledgeTask.Result.Sectors, StartBy = application.StartDate, Status = application.Status, OpportunityId = application.PledgeId, PledgeAmount = pledgeTask.Result.Amount, SenderEmployerAccountId = application.SenderEmployerAccountId, AmountUsed = application.AmountUsed, NumberOfApprenticesUsed = application.NumberOfApprenticesUsed, AutomaticApproval = application.AutomaticApproval, IsWithdrawableAfterAcceptance = IsWithdrawableAfterAcceptance }); }
private async Task <bool> IsLegalEntityOnFjaaRegister(long accountLegalEntityId) { if (accountLegalEntityId == 0 || !_featureToggles.ApprovalsFeatureToggleFjaaEnabled) { return(false); } _logger.LogInformation($"Requesting AccountLegalEntity {accountLegalEntityId} from Commitments v2 Api"); var accountLegalEntity = await _commitmentsV2ApiClient.Get <GetAccountLegalEntityResponse>(new GetAccountLegalEntityRequest(accountLegalEntityId)); _logger.LogInformation($"Requesting fjaa agency for LegalEntityId {accountLegalEntity.MaLegalEntityId}"); var agencyRequest = await _fjaaClient.GetWithResponseCode <GetAgencyResponse>(new GetAgencyRequest(accountLegalEntity.MaLegalEntityId)); if (agencyRequest.StatusCode == HttpStatusCode.NotFound) { return(false); } agencyRequest.EnsureSuccessStatusCode(); return(true); }
public async Task <GetDraftApprenticeshipsResult> Handle(GetDraftApprenticeshipsQuery request, CancellationToken cancellationToken) { var response = await _apiClient.Get <GetDraftApprenticeshipsResponse>(new GetDraftApprenticeshipsRequest(request.CohortId)); if (response == null) { return(null); } return(new GetDraftApprenticeshipsResult { DraftApprenticeships = response.DraftApprenticeships.Select(x => (DraftApprenticeship)x).ToList() }); }
public async Task <GetInformQueryResult> Handle(GetInformQuery request, CancellationToken cancellationToken) { var apprenticeship = await _commitmentsV2ApiClient.Get <GetApprenticeshipResponse>(new GetApprenticeshipRequest(request.ApprenticeshipId)); if (apprenticeship == null || apprenticeship.ProviderId != request.ProviderId) { return(null); } return(new GetInformQueryResult { ApprenticeshipId = request.ApprenticeshipId, LegalEntityName = apprenticeship.EmployerName, }); }
public async Task <GetSelectDeliveryModelResult> Handle(GetSelectDeliveryModelQuery request, CancellationToken cancellationToken) { var apprenticeship = await _commitmentsV2ApiClient.Get <GetApprenticeshipResponse>(new GetApprenticeshipRequest(request.ApprenticeshipId)); if (apprenticeship == null || apprenticeship.ProviderId != request.ProviderId) { return(null); } var deliveryModels = await _deliveryModelService.GetDeliveryModels(apprenticeship.ProviderId, apprenticeship.CourseCode, request.AccountLegalEntityId, request.ApprenticeshipId); return(new GetSelectDeliveryModelResult { ApprenticeshipId = request.ApprenticeshipId, LegalEntityName = apprenticeship.EmployerName, DeliveryModels = deliveryModels }); }
public async Task <GetAllLearnersResult> Handle(GetAllLearnersQuery request, CancellationToken cancellationToken) { var result = await _commitmentsV2ApiClient.Get <GetAllLearnersResponse>(new GetAllLearnersRequest(request.SinceTime, request.BatchNumber, request.BatchSize )); return(new GetAllLearnersResult(result)); }