Esempio n. 1
0
        public async Task <ActionResult <List <CommodityViewModel> > > Get([FromQuery] CommodityQuery query)
        {
            var dbQuery = _commodityRepository.GetQueriable();

            if (!string.IsNullOrEmpty(query.SearchTerm))
            {
                dbQuery = dbQuery.Where(x => x.Title.Contains(query.SearchTerm) || x.Code.Contains(query.SearchTerm));
            }
            return(Ok(dbQuery.Pagenate(query).ProjectTo <CommodityViewModel>(_mapper.ConfigurationProvider).ToList()));
        }