private IQueryable <Book> SearchInBook(ISearchBook search, ref IQueryable <Book> books) { if (search != null && books != null) { if (search.Id > 0) { books = books.Where(b => b.Id == search.Id); } else { if (search.AuthorId > 0) { books = books.Where(b => b.AuthorId == search.AuthorId); } if (search.GenreId > 0) { books = books.Where(b => b.GenreId == search.GenreId); } if (!String.IsNullOrWhiteSpace(search.Title)) { books = books.Where(b => b.Title.Contains(search.Title)); } } } return(books); }
public IPagedList <IMainBook> GetPageWithBooks(int page, ISearchBook search) { int pageSize = 10; if (page < 1) { page = 1; } return(GetBooks(search).ToPagedList(page, pageSize)); }
private IEnumerable <IMainBook> GetBooks(ISearchBook search) { var data = GetBookRecordsQuaryable(); data = SearchInBook(search, ref data); var books = data .OrderBy(b => b.Title) .Select(b => new MainBook { Id = b.Id, Title = b.Title, Author = b.Author.Name, Genre = b.Genre.Name, Description = b.Description }); return(books); }
public BookController(IBookView view, IBookAddView addView, IBookService service, ISearchBook bookSearch, ISearchBookResults bookResults) { this.service = service; this.view = view; this.addView = addView; this.view.SetController(this); this.addView.SetController(this); this.bookSearch = bookSearch; this.bookSearch.SetController(this); this.bookResults = bookResults; this.bookResults.SetController(this); }
public SearchBookController(ISearchBook searchBook) { _searchBook = searchBook; }