public async Task <List <Books> > GetAllBooks(BooksRequestParams vm) { var query = _dataContext.Books.AsQueryable(); if (!(string.IsNullOrWhiteSpace(vm.ISBN))) { query = query.Where(x => EF.Functions.Like(x.ISBN, $"%{vm.ISBN}%")); } if (!(string.IsNullOrWhiteSpace(vm.Title))) { query = query.Where(x => EF.Functions.Like(x.Title, $"%{vm.Title}%")); } if (vm.Status != null) { query = query.Where(x => x.Status == vm.Status); } return(await query.ToListAsync()); }
public async Task <IEnumerable <BooksModel> > GetAllBooks(BooksRequestParams vm) { var model = await _booksReprository.GetAllBooks(vm); return(_mapper.Map <IEnumerable <BooksModel> >(model)); }
public async Task <IActionResult> GetAllBooks(BooksRequestParams vm) { return(Ok(await _booksManager.GetAllBooks(vm))); }