public IActionResult MainCatalogByGenre(int?genreId) { if (genreId == null || db.Genres.Find(genreId) == null) { return(NotFound()); } MainCatalogViewModel cvm = new MainCatalogViewModel { SelectedGenre = db.Genres.Find(genreId), Genres = db.Genres.OrderBy(g => g.Name), TextBooks = db.TextBooks .AsEnumerable() .Where(b => BooksFilteringHelper.GenresContains(b.Genres, genreId)) .OrderBy(b => b.BookName) .Take(10), AudioBooks = db.AudioBooks .AsEnumerable() .Where(b => BooksFilteringHelper.GenresContains(b.Genres, genreId)) .OrderBy(b => b.BookName) .Take(10) }; return(View("~/Views/Catalog/MainCatalog.cshtml", cvm)); }
public IActionResult MainCatalog() { MainCatalogViewModel cvm = new MainCatalogViewModel { Genres = db.Genres.OrderBy(g => g.Name), TextBooks = db.TextBooks .OrderBy(b => b.BookName) .Take(10), AudioBooks = db.AudioBooks .OrderBy(b => b.BookName) .Take(10), Description = db.Descriptions.FirstOrDefault(d => d.TargetName == "Book Catalog Description") }; return(View(cvm)); }
public IActionResult MainCatalogBySearch(string search) { MainCatalogViewModel cvm = new MainCatalogViewModel { SearchString = search, Genres = db.Genres.OrderBy(g => g.Name), TextBooks = db.TextBooks .AsEnumerable() .Where(b => BooksFilteringHelper.IsSearchedBook(b, search)) .OrderBy(b => b.BookName) .Take(10), AudioBooks = db.AudioBooks .AsEnumerable() .Where(b => BooksFilteringHelper.IsSearchedBook(b, search)) .OrderBy(b => b.BookName) .Take(10) }; return(View("~/Views/Catalog/MainCatalog.cshtml", cvm)); }