public ActionResult Search(string title) { var genreModel = new ContribeBookStore.Models.Genre(); try { // Retrieve Genre and its Associated books from database //var genreModel = storeDB.books.Single(g => g.Title == title); genreModel = storeDB.Genres.Include("Books").Single(g => g.Books.FirstOrDefault().Title.Contains(title)); return(View(genreModel)); } catch { ViewBag.ErrorMessage = "Books not found..."; return(View(genreModel)); } }
public ActionResult Browse(string Genre) { var genre = new ContribeBookStore.Models.Genre(); try { // Retrieve Genre and its Associated Books from database var genreModel = storeDB.Genres.Include("Books") .Single(g => g.Name == Genre); return(View(genreModel)); } catch { ViewBag.ErrorMessage = "Books not found..."; return(View(genre)); } }