示例#1
0
 public IActionResult Search([FromBody] SearchProductDto body)
 {
     try
     {
         var result = repository.Queryable().Where(item => item.WareHouseId == body.WareHouseId || item.TypeId == body.TypeId || item.Title == body.Title).ToList();
         return(Ok(result));
     }
     catch
     {
         throw;
     }
 }
示例#2
0
        public async Task <IEnumerable <ProductDto> > SearchProduct(SearchProductDto searchProductResource)
        {
            var productListQuery = await GetProductList();

            if (searchProductResource.SearchText != null)
            {
                productListQuery = productListQuery.Where(x => x.Title.Contains(searchProductResource.SearchText));
            }
            if (searchProductResource.SearchType == 3)
            {
                productListQuery = productListQuery.OrderBy(x => x.Price);
            }
            if (searchProductResource.SearchType == 4)
            {
                productListQuery = productListQuery.OrderByDescending(x => x.Price);
            }

            var searchProductResultResource = _mapper.Map <IEnumerable <Product>, IEnumerable <ProductDto> >(productListQuery);

            return(searchProductResultResource);
        }
示例#3
0
 public IActionResult GetProduct(SearchProductDto product, int page, int limit)
 {
     return(Ok(new { data = template.templateSearch.Search(product, out int count, page, limit), count = count }));