Esempio n. 1
0
        public async Task <IActionResult> GetCalculationsForSpecification(string specificationId,
                                                                          CalculationType calculationType, int pageNumber, [FromQuery] string searchTerm, [FromQuery] string status)
        {
            Guard.ArgumentNotNull(specificationId, nameof(specificationId));

            PublishStatus?publishStatus = null;

            if (!string.IsNullOrEmpty(status) && status != "All")
            {
                publishStatus = (PublishStatus)Enum.Parse(typeof(PublishStatus), status);
            }

            ApiResponse <SearchResults <CalculationSearchResult> > result =
                await _calcClient.SearchCalculationsForSpecification(specificationId,
                                                                     calculationType, publishStatus, searchTerm, pageNumber);

            if (result.StatusCode == HttpStatusCode.OK)
            {
                return(Ok(result.Content));
            }

            return(BadRequest(result.Content));
        }
        public async Task <CalculationSearchResultViewModel> PerformSearch(string specificationId,
                                                                           CalculationType calculationType,
                                                                           PublishStatus?status,
                                                                           string searchTerm,
                                                                           int?page)
        {
            ApiResponse <SearchResults <CalculationSearchResult> > calculationsResult = await _calculationsApiClient.SearchCalculationsForSpecification(specificationId,
                                                                                                                                                        calculationType,
                                                                                                                                                        status,
                                                                                                                                                        searchTerm,
                                                                                                                                                        page);

            return(BuildResults(calculationsResult, page.GetValueOrDefault(1), 50));
        }