Example #1
0
        public async Task <List <Product_Update_And_List_Dto> > get_products(Product_Search_Criteria_Dto search)
        {
            var predicate = PredicateBuilder.True <Product>();

            // var query  = Enumerable<Product>();
            IEnumerable <Product> query = new List <Product>();

            if (search.company_id > 0)
            {
                predicate.And(p => p.company_id == search.company_id);
            }

            if (search.product_Category_id > 0)
            {
                predicate = predicate.And(p => p.product_Category_id == search.product_Category_id);
            }

            if (search.product_Category_id > 0)
            {
                predicate = predicate.And(p => p.product_Category_id == search.product_Category_id);
            }

            if (!string.IsNullOrEmpty(search.product_code))
            {
                predicate = predicate.And(p => p.product_code.ToLower().Contains(search.product_code));
            }

            if (!string.IsNullOrEmpty(search.name))
            {
                predicate = predicate.And(p => p.name.ToLower().Contains(search.name));
            }

            query = await _unitOfWork_Product_Management.repo_products.Find(predicate);

            return(_mapper.Map <List <Product_Update_And_List_Dto> >(query));
        }
Example #2
0
        public async Task <IActionResult> GetProducts([FromQuery] Product_Search_Criteria_Dto search)
        {
            var prods = await _product_Queries.get_products(search);

            return(Ok(prods));
        }