public async Task <ActionResult <MainResponse <List <News> > > > Search(AdminSearchDto searchDto) { var result = await _newsService.Search(searchDto); return(new MainResponse <List <News> > { Path = HttpContext.Request.Path, Message = "Successfully found News", Data = result }); }
public async Task <List <News> > Search(AdminSearchDto adminSearch) { IQueryable <News> query = _dataContext.News; if (adminSearch.Title != null) { query = _dataContext.News.Where(n => n.Title.Contains(adminSearch.Title)); } if (adminSearch.CreatedBy != null) { query = _dataContext.News.Where(n => n.CreatedBy == adminSearch.CreatedBy); } if (adminSearch.UpdatedBy != null) { query = _dataContext.News.Where(n => n.UpdatedBy == adminSearch.UpdatedBy); } return(await query.ToListAsync()); }