//gets all items that got added during the last 14 days public ActionResult Index() { IList <LibraryItem> newitems = new List <LibraryItem>(); IEnumerable <LibraryItem> dvds = LibraryItemService.CastDVDsToLibraryItems(_dvdService.GetNewDVDs()); IEnumerable <LibraryItem> books = LibraryItemService.CastBooksToLibraryItems(_bookService.GetNewBooks()); return(View(newitems.Concat(books).Concat(dvds))); }
//gets all overdue items and filters them by the entered searchString public ActionResult GetOverdueLibraryItems(string searchString) { IList <LibraryItem> overdueItems = LibraryItemService.AssignCorrectGenre(_libraryItemService.GetOverdueLibraryItems()); IList <LibraryItem> items = new List <LibraryItem>(); if (String.IsNullOrEmpty(searchString)) { return(View(overdueItems)); } else { items = _libraryItemService.TextSearch(overdueItems, searchString); return(View(items)); } }
//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)); }
//Returns a list of loaned library items for the selected user in Staff/Admin View public ActionResult GetLoanedLibraryItemsOfUser(string id) { IList <LibraryItem> loanedItems = LibraryItemService.AssignCorrectGenre(_libraryItemService.GetLoanedLibraryItemsOfUser(id)); return(View(loanedItems)); }