public QueryContainer Create <TRequest>(TRequest request, QueryContainerDescriptor <QueryableAsset> q)
        {
            GetAssetListRequest assetListRequest = request as GetAssetListRequest;

            if (assetListRequest == null)
            {
                throw new ArgumentNullException($"{nameof(request).ToString()} shouldn't be null.");
            }

            return(_queryBuilder
                   .WithWildstarQuery(assetListRequest.SearchText,
                                      new List <string> {
                "assetAddress.addressLine1", "assetAddress.postCode", "assetAddress.uprn"
            })
                   .WithExactQuery(assetListRequest.SearchText,
                                   new List <string>
            {
                "assetAddress.addressLine1",
                "assetAddress.uprn",
                "assetAddress.postCode"
            })
                   .WithFilterQuery(assetListRequest.AssetTypes, new List <string> {
                "assetType"
            })
                   .Build(q));
        }
Esempio n. 2
0
        public async Task GetAssetListShouldCallGetAssetListUseCase()
        {
            // given
            var request  = new GetAssetListRequest();
            var response = new GetAssetListResponse();

            _mockGetAssetListUseCase.Setup(x => x.ExecuteAsync(request)).ReturnsAsync(response);

            // when
            await _classUnderTest.GetAssetList(request).ConfigureAwait(false);

            // then
            _mockGetAssetListUseCase.Verify(x => x.ExecuteAsync(request), Times.Once);
        }
        public async Task <GetAssetListResponse> GetListOfAssets(GetAssetListRequest query)
        {
            var searchResponse = await _elasticSearchWrapper.Search <QueryableAsset, GetAssetListRequest>(query).ConfigureAwait(false);

            var assetListResponse = new GetAssetListResponse();

            assetListResponse.Assets.AddRange(searchResponse.Documents.Select(queryableAsset =>
                                                                              queryableAsset.Create())
                                              );

            assetListResponse.SetTotal(searchResponse.Total);

            return(assetListResponse);
        }
Esempio n. 4
0
        public async Task <IActionResult> GetAssetList([FromQuery] GetAssetListRequest request)
        {
            try
            {
                var assetsSearchResult = await _getAssetListUseCase.ExecuteAsync(request).ConfigureAwait(false);

                var apiResponse = new APIResponse <GetAssetListResponse>(assetsSearchResult);
                apiResponse.Total = assetsSearchResult.Total();

                return(new OkObjectResult(apiResponse));
            }
            catch (Exception e)
            {
                LambdaLogger.Log(e.Message + e.StackTrace);
                return(new BadRequestObjectResult(e.Message));
            }
        }
 public async Task <GetAssetListResponse> ExecuteAsync(GetAssetListRequest housingSearchRequest)
 {
     return(await _searchGateway.GetListOfAssets(housingSearchRequest).ConfigureAwait(false));
 }