Exemplo n.º 1
0
        public async Task <ApiResponse <SearchResults <CalculationSearchResult> > > FindCalculations(SearchFilterRequest filterOptions)
        {
            Guard.ArgumentNotNull(filterOptions, nameof(filterOptions));

            SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions);

            string url = $"{UrlRoot}/calculations-search";

            ApiResponse <SearchResults <CalculationSearchResult> > results = await PostAsync <SearchResults <CalculationSearchResult>, SearchQueryRequest>(url, request);

            return(results);
        }
Exemplo n.º 2
0
        public async Task <PagedResult <DatasetVersionSearchResultModel> > FindDatasetsVersions(SearchFilterRequest searchFilterRequest)
        {
            SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(searchFilterRequest);

            ApiResponse <SearchResults <DatasetVersionSearchResultModel> > apiResponse =
                await PostAsync <SearchResults <DatasetVersionSearchResultModel>, SearchQueryRequest>($"datasets-version-search", request);

            if (apiResponse.StatusCode == HttpStatusCode.OK)
            {
                PagedResult <DatasetVersionSearchResultModel> result = new SearchPagedResult <DatasetVersionSearchResultModel>(searchFilterRequest, apiResponse.Content.TotalCount)
                {
                    Items = apiResponse.Content.Results
                };

                return(result);
            }
            return(null);
        }
Exemplo n.º 3
0
        public async Task <PagedResult <SpecificationSearchResultItem> > FindSpecifications(SearchFilterRequest filterOptions)
        {
            SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions);

            ApiResponse <SearchResults <SpecificationSearchResultItem> > results = await PostAsync <SearchResults <SpecificationSearchResultItem>, SearchQueryRequest>("specifications-search", request);

            if (results.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            PagedResult <SpecificationSearchResultItem> result = new SearchPagedResult <SpecificationSearchResultItem>(filterOptions, results.Content.TotalCount)
            {
                Items  = results.Content.Results,
                Facets = results.Content.Facets,
            };

            return(result);
        }
Exemplo n.º 4
0
        public async Task <PagedResult <SpecificationDatasourceRelationshipSearchResultItem> > FindSpecificationAndRelationships(SearchFilterRequest filterOptions)
        {
            Guard.ArgumentNotNull(filterOptions, nameof(filterOptions));

            SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions);

            ApiResponse <SearchResults <SpecificationDatasourceRelationshipSearchResultItem> > results = await PostAsync <SearchResults <SpecificationDatasourceRelationshipSearchResultItem>, SearchQueryRequest>("specifications-dataset-relationships-search", request);

            if (results.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            PagedResult <SpecificationDatasourceRelationshipSearchResultItem> result = new SearchPagedResult <SpecificationDatasourceRelationshipSearchResultItem>(filterOptions, results.Content.TotalCount)
            {
                Items = results.Content.Results
            };

            return(result);
        }
        public async Task <PagedResult <ProviderVersionSearchResult> > SearchMasterProviders(SearchFilterRequest filterOptions)
        {
            Guard.ArgumentNotNull(filterOptions, nameof(filterOptions));

            SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions);

            SearchModel searchModel = new SearchModel
            {
                PageNumber    = filterOptions.Page,
                Top           = filterOptions.PageSize,
                SearchTerm    = filterOptions.SearchTerm,
                IncludeFacets = filterOptions.IncludeFacets,
                Filters       = filterOptions.Filters ?? new Dictionary <string, string[]>(),
                FacetCount    = filterOptions.FacetCount,
                SearchMode    = filterOptions.SearchMode == ApiClient.Models.SearchMode.All ? Common.Models.Search.SearchMode.All : Common.Models.Search.SearchMode.Any,
                ErrorToggle   = filterOptions.ErrorToggle
            };

            ApiResponse <ProviderVersionSearchResults> results = await SearchMasterProviders(searchModel);

            if (results.StatusCode == HttpStatusCode.OK)
            {
                PagedResult <ProviderVersionSearchResult> result = new SearchPagedResult <ProviderVersionSearchResult>(filterOptions, results.Content.TotalCount)
                {
                    Items  = results.Content.Results,
                    Facets = results.Content.Facets.Select(x => new SearchFacet
                    {
                        Name        = x.Name,
                        FacetValues = x.FacetValues.Select(v => new SearchFacetValue {
                            Name = v.Name, Count = v.Count
                        })
                    }),
                };

                return(result);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
        public async Task FindCalculations()
        {
            SearchFilterRequest input           = new SearchFilterRequest();
            SearchQueryRequest  expectedRequest = SearchQueryRequest.FromSearchFilterRequest(input);
            SearchResults <CalculationSearchResult> expectedResults = new SearchResults <CalculationSearchResult>();

            GivenTheResponse("calculations-search", expectedResults, HttpMethod.Post);

            ApiResponse <SearchResults <CalculationSearchResult> > apiResponse = await _client.FindCalculations(input);

            apiResponse?.StatusCode
            .Should()
            .Be(HttpStatusCode.OK);

            apiResponse
            .Content
            .Should()
            .BeEquivalentTo(expectedResults);

            AndTheRequestContentsShouldHaveBeen(expectedRequest.AsJson());
        }
Exemplo n.º 7
0
        public async Task <PagedResult <TestScenarioSearchResultItem> > FindTestScenariosForProvider(SearchFilterRequest filterOptions)
        {
            Guard.ArgumentNotNull(filterOptions, nameof(filterOptions));

            SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions);

            ApiResponse <SearchResults <TestScenarioSearchResultItem> > results = await PostAsync <SearchResults <TestScenarioSearchResultItem>, SearchQueryRequest>("testscenario-search", request);

            if (results.StatusCode == HttpStatusCode.OK)
            {
                PagedResult <TestScenarioSearchResultItem> result = new SearchPagedResult <TestScenarioSearchResultItem>(filterOptions, results.Content.TotalCount)
                {
                    Items = results.Content.Results
                };

                return(result);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 8
0
        public async Task <PagedResult <DatasetSearchResultItem> > FindDatasets(SearchFilterRequest filterOptions)
        {
            Guard.ArgumentNotNull(filterOptions, nameof(filterOptions));

            SearchQueryRequest request = SearchQueryRequest.FromSearchFilterRequest(filterOptions);

            ApiResponse <SearchResults <DatasetSearchResultItem> > results = await PostAsync <SearchResults <DatasetSearchResultItem>, SearchQueryRequest>("datasets-search", request);

            if (results.StatusCode == HttpStatusCode.OK)
            {
                PagedResult <DatasetSearchResultItem> result = new SearchPagedResult <DatasetSearchResultItem>(filterOptions, results.Content.TotalCount)
                {
                    Items  = results.Content.Results,
                    Facets = results.Content.Facets,
                };

                return(result);
            }
            else
            {
                return(null);
            }
        }