public IQueryable <ITblProduct> GetFiltered(IQueryable <ITblProduct> query, IProductFilterModel filter)
 {
     if (!String.IsNullOrEmpty(filter.Name))
     {
         return(query.Where(x => x.Name.ToLower().Contains(filter.Name.ToLower())));
     }
     else
     {
         return(query);
     }
 }
Beispiel #2
0
        public IResultModel GetProductByFilter(IProductFilterModel filter)
        {
            IResultModel res = new ResultModel();

            try
            {
                var query = _repository.GetProducts();
                query = _filterByName.GetFiltered(query, filter);
                var innerRes = query.ToList();
                res.body = innerRes;
                return(res);
            }
            catch (Exception ex)
            {
                res.errorMessage = ex.Message;
                _logger.LogError(ex.Message);
                return(res);
            }
        }