Exemple #1
0
        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));
            }
        }
Exemple #2
0
        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));
            }
        }