public async Task Run() { const long ukprn = 10005077; var hasRelationshipWithPermissionRequest = new HasRelationshipWithPermissionRequest { Ukprn = ukprn, Operation = Operation.CreateCohort }; var hasRelationshipWithPermission = await _providerRelationshipsApiClient.HasRelationshipWithPermission(hasRelationshipWithPermissionRequest); Console.WriteLine($"Calling HasRelationshipWithPermission with Ukprn {hasRelationshipWithPermissionRequest.Ukprn}, Operation {hasRelationshipWithPermissionRequest.Operation} returned {hasRelationshipWithPermission}"); }
public async Task <CohortsViewModel> Map(CohortsByProviderRequest source) { async Task <(CohortSummary[] Cohorts, bool HasRelationship, ProviderAgreementStatus providerAgreementStatus)> GetData() { var getCohortsTask = _commitmentsApiClient.GetCohorts(new GetCohortsRequest { ProviderId = source.ProviderId }); var hasRelationshipTask = _providerRelationshipsApiClient.HasRelationshipWithPermission(new HasRelationshipWithPermissionRequest { Ukprn = source.ProviderId, Operation = Operation.CreateCohort }); var providerAgreement = _pasAccountApiClient.GetAgreement(source.ProviderId); await Task.WhenAll(getCohortsTask, hasRelationshipTask, providerAgreement); return(getCohortsTask.Result.Cohorts, hasRelationshipTask.Result, providerAgreement.Result.Status); } var data = await GetData(); return(new CohortsViewModel { ProviderId = source.ProviderId, ShowDrafts = (data.HasRelationship), CohortsInDraft = new CohortCardLinkViewModel( data.Cohorts.Count(x => x.GetStatus() == CohortStatus.Draft), "drafts", _urlHelper.Action("Draft", "Cohort", new { source.ProviderId }), CohortStatus.Draft.ToString()), CohortsInReview = new CohortCardLinkViewModel( data.Cohorts.Count(x => x.GetStatus() == CohortStatus.Review), "ready to review", _urlHelper.Action("Review", "Cohort", new { source.ProviderId }), CohortStatus.Review.ToString()), CohortsWithEmployer = new CohortCardLinkViewModel( data.Cohorts.Count(x => x.GetStatus() == CohortStatus.WithEmployer), "with employers", _urlHelper.Action("WithEmployer", "Cohort", new { source.ProviderId }), CohortStatus.WithEmployer.ToString()), CohortsWithTransferSender = new CohortCardLinkViewModel( data.Cohorts.Count(x => x.GetStatus() == CohortStatus.WithTransferSender), "with transfer sending employers", _urlHelper.Action("WithTransferSender", "Cohort", new { source.ProviderId }), CohortStatus.WithTransferSender.ToString()), IsAgreementSigned = data.providerAgreementStatus == ProviderAgreementStatus.Agreed }); }
public async Task <WithTransferSenderViewModel> Map(CohortsByProviderRequest source) { async Task <(CohortSummary[] Cohorts, bool HasRelationship, ProviderAgreementStatus providerAgreementStatus)> GetData() { var getCohortsTask = _commitmentsApiClient.GetCohorts(new GetCohortsRequest { ProviderId = source.ProviderId }); var hasRelationshipTask = _providerRelationshipsApiClient.HasRelationshipWithPermission(new HasRelationshipWithPermissionRequest { Ukprn = source.ProviderId, Operation = Operation.CreateCohort }); var providerAgreement = _pasAccountApiClient.GetAgreement(source.ProviderId); await Task.WhenAll(getCohortsTask, hasRelationshipTask); return(getCohortsTask.Result.Cohorts, hasRelationshipTask.Result, providerAgreement.Result.Status); } var(cohorts, hasRelationship, providerAgreementStatus) = await GetData(); var reviewViewModel = new WithTransferSenderViewModel { ProviderId = source.ProviderId, SortField = source.SortField, ReverseSort = source.ReverseSort, ApprenticeshipRequestsHeaderViewModel = cohorts.GetCohortCardLinkViewModel(_urlHelper, source.ProviderId, CohortStatus.WithTransferSender, hasRelationship, providerAgreementStatus), Cohorts = cohorts .Where(x => x.GetStatus() == CohortStatus.WithTransferSender) .Select(y => new WithTransferSenderCohortSummaryViewModel { CohortReference = _encodingService.Encode(y.CohortId, EncodingType.CohortReference), EmployerName = y.LegalEntityName, NumberOfApprentices = y.NumberOfDraftApprentices, DateSentToEmployer = GetOrderByDate(y) }) .ApplyOrder(source.SortField, source.ReverseSort) .ToList() }; return(reviewViewModel); }
public async Task <GetProviderHasRelationshipWithPermissionQueryResponse> Handle( GetProviderHasRelationshipWithPermissionQueryRequest request, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return(new GetProviderHasRelationshipWithPermissionQueryResponse()); } var apiRequest = new HasRelationshipWithPermissionRequest { Operation = request.Permission, Ukprn = request.ProviderId }; var result = await _providerRelationshipsApiClient.HasRelationshipWithPermission(apiRequest, cancellationToken); return(new GetProviderHasRelationshipWithPermissionQueryResponse { HasPermission = result }); }