Beispiel #1
0
        public async Task <IActionResult> GetProducts([FromQuery] ProductsSearchRequest productsRequest, CancellationToken cancellationToken)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var getProductsRequest = new GetProductsRequest()
            {
                PageNumber   = productsRequest.PageNumber,
                PageSize     = productsRequest.PageSize,
                ProductName  = productsRequest.ProductSearchName,
                CategoryId   = productsRequest.CategoryId,
                LoadCategory = true,
                CalculateTotalProductsCount = true
            };

            var searchResult = await _mediator.Send(getProductsRequest, cancellationToken);

            var productItems    = _mapper.Map <IEnumerable <ProductItemDto> >(searchResult.FoundProducts);
            var searchResultDto = new ProductsSearchResultDto()
            {
                TotalProductsCount = searchResult.TotalProductsCount.GetValueOrDefault(),
                ProductItems       = productItems
            };

            return(Ok(searchResultDto));
        }
Beispiel #2
0
        private async Task FilterProducts()
        {
            var search = new ProductsSearchRequest()
            {
                ProductName = txtSearch.Text
            };
            var result = await _productsService.Get <List <Model.Products> >(search);

            var newList = new List <Model.Products>();

            foreach (var item in result)
            {
                var availableQuantity = await Helper.numInStorage(item.Id) - GetQuantityFromModel(item.Id);

                if (availableQuantity != 0)
                {
                    newList.Add(item);
                }
            }

            dgvProducts.AutoGenerateColumns = false;
            dgvProducts.DataSource          = newList;
            numProducts.Value   = 0;
            numProducts.Maximum = 0;
        }
        public async Task Init()
        {
            if (ProductTypesList.Count == 0)
            {
                var productTypesList = await _productTypesService.Get <List <ProductTypes> >(null);

                ProductTypesList.Add(new ProductTypes("All"));
                foreach (var item in productTypesList)
                {
                    ProductTypesList.Add(item);
                }
            }

            if (SelectedProductTypes != null)
            {
                ProductsSearchRequest searchRequest = new ProductsSearchRequest();
                if (SelectedProductTypes.Name == "All")
                {
                    searchRequest = null;
                }
                else
                {
                    searchRequest.ProductTypeId = SelectedProductTypes.Id;
                }
                var list = await _service.Get <IEnumerable <Products> >(searchRequest);

                ProductsList.Clear();
                foreach (var item in list)
                {
                    ProductsList.Add(item);
                }
            }
        }
        public async Task <DocumentSearchResult> Get(ProductsSearchRequest request)
        {
            var parameters = new ProductsSearchParameters(request);

            request.Keyword = GetFuzzyString(request.Keyword);

            var results = await _indexClient.Documents.SearchAsync(request.Keyword, parameters);

            return(results);
        }
Beispiel #5
0
 public ActionResult SearchProducts(ProductsSearchRequest searchRequest)
 {
     return(this.Execute(
                () =>
     {
         var searchOptions =
             this.searchMapper.Map <ProductsSearchRequest, ProductSearchOptions>(searchRequest);
         return this.productSearchService.GetProducts(searchOptions);
     }));
 }
Beispiel #6
0
        private async void btnSearch_Click(object sender, EventArgs e)
        {
            var search = new ProductsSearchRequest()
            {
                ProductName = txtSearch.Text
            };
            var result = await _productsService.Get <List <Model.Products> >(search);

            dgvProducts.AutoGenerateColumns = false;
            dgvProducts.DataSource          = result;
        }
        public async Task SearchedProducts(string serachBar)
        {
            ProductsSearchRequest request = new ProductsSearchRequest
            {
                ProductName = serachBar
            };

            ProductsList.Clear();
            var list = await _service.Get <IEnumerable <Model.Products> >(request);

            foreach (var item in list)
            {
                ProductsList.Add(item);
            }
        }
        private async void btnSearch_Click(object sender, EventArgs e)
        {
            if (_orders == null)
            {
                var search = new ProductsSearchRequest()
                {
                    ProductName = txtSearchName.Text
                };
                var result = await _products.Get <List <Model.Products> >(search);

                dgvProducts.AutoGenerateColumns = false;
                dgvProducts.DataSource          = result;
            }
            else
            {
                await LoadProductsFromOrder();
            }
        }
Beispiel #9
0
        private async Task LoadProducts()
        {
            var search = new ProductsSearchRequest()
            {
                ProductName = txtSearch.Text
            };
            List <Model.Products> result = await _productsService.Get <List <Model.Products> >(search);

            List <Model.Products> newList = new List <Model.Products>(result);

            foreach (var item in result)
            {
                if (_productsAdd.Where(x => x.ProductId == item.Id).Any())
                {
                    newList.Remove(item);
                }
            }
            dgvProducts.AutoGenerateColumns = false;
            dgvProducts.DataSource          = newList;
        }
 /// <summary>
 /// taobao.products.search
 /// 搜索产品信息(B商家专用)
 /// </summary>
 /// <param name="fields">必填 需返回的字段列表.可选值:Product数据结构中的以下字段:product_id,name,pic_url,cid,props,price,tsc;多个字段之间用"</param>
 /// <param name="keywords">搜索的关键词是用来搜索产品的title. 注:q,cid和props至少传入一个</param>
 /// <param name="cid">商品类目ID</param>
 /// <param name="props">属性,属性值的组合.格式:pid:vid;pid:vid;</param>
 /// <param name="status">想要获取的产品的状态列表,支持多个状态并列获取,多个状态之间用","分隔,最多同时指定5种状态。例如,只获取小二确认的spu传入"3",只要商家确认的传入"0",既要小二确认又要商家确认的传入"0,3"。目前只支持者两种类型的状态搜索,输入其他状态无效。</param>
 /// <param name="pageno">页码</param>
 /// <param name="pagesize">每页条数.每页返回最多返回100条,默认值为40. </param>
 /// <param name="verticalmarket">传入值为:3表示3C表示3C垂直市场产品,4表示鞋城垂直市场产品,8表示网游垂直市场产品。一次只能指定一种垂直市场类型 </param>
 /// <param name="customerprops">用户自定义关键属性,结构:pid1:value1;pid2:value2,如果有型号,系列等子属性用: 隔开</param>
 /// <param name="marketid">市场ID,1为取C2C市场的产品信息, 2为取B2C市场的产品信息。 不填写此值则默认取C2C的产品信息。</param>
 /// <returns></returns>
 public static List<Product> GetProductsBySearch(string fields, string keywords, long? cid, string props, string status,
     long? pageno, long? pagesize, long? verticalmarket, string customerprops, string marketid, out long recordcount)
 {
     ITopClient client = TopClientService.GetTopClient();
     ProductsSearchRequest req = new ProductsSearchRequest();
     req.Fields = fields;
     req.Q = keywords;
     req.Cid = cid;
     req.Props = props;
     req.Status = status;
     req.PageNo = pageno;
     req.PageSize = pagesize;
     req.VerticalMarket = verticalmarket;
     req.CustomerProps = customerprops;
     req.MarketId = marketid;
     ProductsSearchResponse response = client.Execute(req);
     recordcount = response.TotalResults;
     return response.Products;
 }