public async Task DeselectSpecificationForFunding(string fundingStreamId, string fundingPeriodId) { _logger.Information($"Deselecting specification for funding for {fundingStreamId} {fundingPeriodId}"); ApiResponse <IEnumerable <SpecificationSummary> > response = await _specsApiPolicy.ExecuteAsync(() => _specificationsApiClient.GetSpecificationsSelectedForFundingByPeriod(fundingPeriodId)); SpecificationSummary specificationSummary = response?.Content? .FirstOrDefault(_ => _.FundingStreams?.Any(fs => fs.Id == fundingStreamId) == true); if (specificationSummary == null) { throw new ArgumentOutOfRangeException(nameof(fundingStreamId), $"Did not locate a specification selected for funding for {fundingStreamId} {fundingPeriodId}"); } HttpStatusCode statusCode = await _specsApiPolicy.ExecuteAsync(() => _specificationsApiClient.DeselectSpecificationForFunding(specificationSummary.Id)); if (!statusCode.IsSuccess()) { throw new InvalidOperationException($"Unable to deselect specification for funding for {fundingStreamId} {fundingPeriodId}"); } }
private void AndDeselectingTheSpecificationIdReportsSuccess(string specificationId) { _specificationsApiClient .DeselectSpecificationForFunding(specificationId) .Returns(HttpStatusCode.OK); }