public async Task <BuildProject> GetBuildProjectForSpecificationId(string specificationId) { BuildProject buildProject = null; if (_featureToggle.IsDynamicBuildProjectEnabled()) { buildProject = await GenerateBuildProject(specificationId); } else { buildProject = await _buildProjectsRepositoryPolicy.ExecuteAsync(() => _buildProjectsRepository.GetBuildProjectBySpecificationId(specificationId)); if (buildProject == null) { buildProject = await GenerateBuildProject(specificationId); await _buildProjectsRepositoryPolicy.ExecuteAsync(() => _buildProjectsRepository.CreateBuildProject(buildProject)); } } return(buildProject); }
public async Task <BuildProject> GetBuildProjectForSpecificationId(string specificationId) { BuildProject buildProject = null; ApiResponse <SpecificationSummary> specificationSummaryResponse = await _specificationsApiClientPolicy.ExecuteAsync(() => _specificationsApiClient.GetSpecificationSummaryById(specificationId)); if (specificationSummaryResponse != null && specificationSummaryResponse.StatusCode == System.Net.HttpStatusCode.NotFound) { throw new EntityNotFoundException($"Specification with ID '{specificationId}' was not found"); } else if (specificationSummaryResponse?.Content == null) { _logger.Error($"Failed to get specification for specification id '{specificationId}'"); throw new ArgumentNullException(nameof(SpecificationSummary)); } SpecificationSummary specificationSummary = specificationSummaryResponse.Content; IEnumerable <Reference> fundingStreams = specificationSummary.FundingStreams; Reference fundingPeriod = specificationSummary.FundingPeriod; IDictionary <string, string> templateIds = specificationSummary.TemplateIds; if (_featureToggle.IsDynamicBuildProjectEnabled()) { buildProject = await GenerateBuildProject(specificationId, fundingStreams.Select(_ => (_, fundingPeriod)), templateIds); } else { buildProject = await _buildProjectsRepositoryPolicy.ExecuteAsync(() => _buildProjectsRepository.GetBuildProjectBySpecificationId(specificationId)); if (buildProject == null) { buildProject = await GenerateBuildProject(specificationId, fundingStreams.Select(_ => (_, fundingPeriod)), templateIds); await _buildProjectsRepositoryPolicy.ExecuteAsync(() => _buildProjectsRepository.CreateBuildProject(buildProject)); } } return(buildProject); }