// GET: DVDs //gets all the books and filters them by the entered searchString, Genre and Status public ActionResult Index(string searchString, string genre, string status, string library, int?page) { IList <DVD> dvdquery = _dvdService.GetDVDs(); var pageNumber = page ?? 1; if (!String.IsNullOrEmpty(searchString)) { dvdquery = DVDTextSearch(dvdquery, searchString); } if (!String.IsNullOrEmpty(genre)) { dvdquery = DVDGenreFilter(dvdquery, genre); } if (!String.IsNullOrEmpty(status)) { dvdquery = DVDStatusFilter(dvdquery, status); } if (!String.IsNullOrEmpty(library)) { dvdquery = DVDLibraryFilter(dvdquery, library); } //show 10 DVDs on one page var onePageOfDVDs = dvdquery.ToPagedList(pageNumber, 10); ViewBag.onePageOfDVDs = onePageOfDVDs; return(View()); }
//gets all the books and dvds from the database, filters them by the entered searchString, genre, status and type public ActionResult Searchbar(string searchString, string genre, string status, string type, string library) { IList <LibraryItem> items = new List <LibraryItem>(); IList <Book> bookquery = _bookService.GetBooks(); IList <DVD> dvdquery = _dvdService.GetDVDs(); if (String.IsNullOrEmpty(searchString) && String.IsNullOrEmpty(genre) && String.IsNullOrEmpty(status) && String.IsNullOrEmpty(type) && String.IsNullOrEmpty(library)) { items = _libraryItemService.GetLibraryItems(); return(View(items)); } if (!String.IsNullOrEmpty(searchString)) { bookquery = BookTextSearch(bookquery, searchString); dvdquery = DVDTextSearch(dvdquery, searchString); } if (!String.IsNullOrEmpty(genre)) { bookquery = BookGenreFilter(bookquery, genre); dvdquery = DVDGenreFilter(dvdquery, genre); } if (!String.IsNullOrEmpty(status)) { bookquery = BookStatusFilter(bookquery, status); dvdquery = DVDStatusFilter(dvdquery, status); } if (!String.IsNullOrEmpty(type)) { bookquery = BookTypeFilter(bookquery, type); dvdquery = DVDTypeFilter(dvdquery, type); } if (!String.IsNullOrEmpty(library)) { bookquery = BookLibraryFilter(bookquery, library); dvdquery = DVDLibraryFilter(dvdquery, library); } //concatenate bookquery and dvdquery to one list of LibraryItems items = items.Concat(LibraryItemService.CastBooksToLibraryItems(bookquery)).Concat(LibraryItemService.CastDVDsToLibraryItems(dvdquery)).ToList(); return(View(items)); }