public async Task <IActionResult> OnGetAsync(int?pageNumber, string searchTerm, string fundingPeriodId = null)
        {
            await PopulatePeriods(fundingPeriodId);

            if (string.IsNullOrWhiteSpace(fundingPeriodId))
            {
                fundingPeriodId = FundingPeriods.First().Value;
            }

            SearchRequestViewModel searchRequest = new SearchRequestViewModel()
            {
                PageNumber    = pageNumber,
                IncludeFacets = false,
                SearchTerm    = searchTerm,
                Filters       = new Dictionary <string, string[]> {
                    { "fundingPeriodId", new[] { fundingPeriodId } }
                }
            };

            SearchTerm = searchTerm;

            SearchResults = await _datasetRelationshipsSearchService.PerformSearch(searchRequest);

            if (SearchResults == null)
            {
                return(new StatusCodeResult(500));
            }

            return(Page());
        }
Ejemplo n.º 2
0
        async Task PopulateAsync(string providerId, string fundingPeriodId = null, string specificationId = null)
        {
            await PopulatePeriods(fundingPeriodId);

            if (string.IsNullOrWhiteSpace(fundingPeriodId))
            {
                fundingPeriodId = FundingPeriods?.First().Value;
            }

            FundingPeriodId = fundingPeriodId;

            await PopulateSpecifications(providerId, specificationId);

            ProviderId = providerId;

            SpecificationId = specificationId;

            ApiResponse <Provider> apiResponse = await _resultsApiClient.GetProviderByProviderId(providerId);

            if (apiResponse.StatusCode != HttpStatusCode.OK && apiResponse.Content == null)
            {
                throw new InvalidOperationException($"Unable to retreive Provider information: Status Code = {apiResponse.StatusCode}");
            }

            Provider response = apiResponse.Content;

            ProviderResultsViewModel viewModel = new ProviderResultsViewModel
            {
                ProviderName    = response.Name,
                ProviderType    = response.ProviderType,
                ProviderSubtype = response.ProviderSubtype,
                LocalAuthority  = response.LocalAuthority,
                Upin            = response.UPIN,
                Ukprn           = response.UKPRN,
                Urn             = response.URN,
                DateOpened      = response.DateOpened.HasValue ? response.DateOpened.Value.ToString("dd/MM/yyyy") : "Unknown"
            };

            ViewModel = viewModel;

            if (!string.IsNullOrWhiteSpace(specificationId))
            {
                ApiResponse <ProviderResults> providerResponse = await _resultsApiClient.GetProviderResults(providerId, specificationId);

                if (providerResponse.StatusCode == HttpStatusCode.OK && providerResponse.Content != null)
                {
                    PopulateResults(providerResponse);
                }
                else
                {
                    _logger.Warning("There were no providers for the given specification Id " + specificationId);
                }
            }
        }
Ejemplo n.º 3
0
        async Task PopulateAsync(string fundingPeriodId, string specificationId)
        {
            await PopulateFundingPeriods(fundingPeriodId);

            if (string.IsNullOrWhiteSpace(fundingPeriodId))
            {
                fundingPeriodId = FundingPeriods.First().Value;
            }

            FundingPeriodId = fundingPeriodId;

            await PopulateSpecifications(fundingPeriodId);
        }
        public async Task <IActionResult> OnGetAsync(int?pageNumber, string searchTerm, string fundingPeriodId = null, string specificationId = null)
        {
            Task populatePeriodsTask = PopulateFundingPeriods(fundingPeriodId);

            TestScenarioResultRequestViewModel testScenarioResultRequestViewModel = new TestScenarioResultRequestViewModel()
            {
                PageNumber      = pageNumber,
                FundingPeriodId = fundingPeriodId,
                SearchTerm      = searchTerm,
                SpecificationId = specificationId,
            };
            Task <TestScenarioResultViewModel> testScenarioResultsTask = _testScenarioResultsService.PerformSearch(testScenarioResultRequestViewModel);

            await TaskHelper.WhenAllAndThrow(testScenarioResultsTask, populatePeriodsTask);

            if (string.IsNullOrWhiteSpace(fundingPeriodId))
            {
                fundingPeriodId = FundingPeriods?.First().Value;
            }

            FundingPeriodId = fundingPeriodId;

            SearchResults = testScenarioResultsTask.Result;
            if (SearchResults == null)
            {
                return(new ObjectResult("Search result was null")
                {
                    StatusCode = 500
                });
            }

            PopulateSpecifications(SearchResults.Specifications);

            InitialSearchResults = JsonConvert.SerializeObject(SearchResults, Formatting.Indented, new JsonSerializerSettings()
            {
                ContractResolver     = new CamelCasePropertyNamesContractResolver(),
                StringEscapeHandling = StringEscapeHandling.EscapeHtml
            });

            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(string providerId, int?pageNumber, string searchTerm = null, string fundingPeriodId = null, string specificationId = null)
        {
            Guard.IsNullOrWhiteSpace(providerId, nameof(providerId));

            ProviderId = providerId;

            SearchRequestViewModel searchRequest = new SearchRequestViewModel()
            {
                PageNumber    = pageNumber,
                IncludeFacets = false,
                SearchTerm    = "",
                Filters       = new Dictionary <string, string[]>
                {
                    { "providerId", new[] { providerId } },
                    { "specificationId", new[] { specificationId } },
                }
            };

            Task populatePeriodsTask = PopulateFundingPeriods(fundingPeriodId);

            Task <ApiResponse <Provider> > apiResponseTask = _resultsApiClient.GetProviderByProviderId(providerId);


            await TaskHelper.WhenAllAndThrow(populatePeriodsTask, apiResponseTask);

            if (string.IsNullOrWhiteSpace(fundingPeriodId))
            {
                fundingPeriodId = FundingPeriods?.First().Value;
            }

            FundingPeriodId = fundingPeriodId;

            await PopulateSpecifications(providerId, specificationId);

            SpecificationId = specificationId;

            ApiResponse <Provider> apiResponse = apiResponseTask.Result;

            if (apiResponse != null && apiResponse.StatusCode == HttpStatusCode.OK && apiResponse.Content != null)
            {
                Provider response = apiResponse.Content;

                ProviderViewModel providerViewModel = _mapper.Map <ProviderViewModel>(apiResponse.Content);

                ProviderInfoModel = providerViewModel;
            }
            else
            {
                _logger.Error("Provider response content is null");
                return(new StatusCodeResult(500));
            }

            if (!string.IsNullOrWhiteSpace(specificationId))
            {
                TestScenarioSearchResults = await _testScenarioSearchService.PerformSearch(searchRequest);

                if (TestScenarioSearchResults != null)
                {
                    Passed  = TestScenarioSearchResults.TestScenarios.Where(c => c.TestResult == "Passed").Count();
                    Failed  = TestScenarioSearchResults.TestScenarios.Where(c => c.TestResult == "Failed").Count();
                    Ignored = TestScenarioSearchResults.TestScenarios.Where(c => c.TestResult == "Ignored").Count();

                    int totalRecords = Passed + Failed + Ignored;
                    if (totalRecords > 0)
                    {
                        TestCoverage = Math.Round((decimal)(Passed + Failed) / totalRecords * 100, 1);
                    }
                }
            }

            return(Page());
        }