Ejemplo n.º 1
0
        /// <summary>
        /// wyswietla wszystkie ksiazki
        /// </summary>
        /// <param name="genreId"></param>
        /// <returns></returns>
        public ViewResult List(int genreId)
        {
            List <string>      _genres = new List <string>();;
            IEnumerable <Book> books;
            string             currentGanre = string.Empty;


            var genre = _genreRepository.GenreByCategory(genreId);;

            if (genreId != 0)
            {
                books = _bookRepository.GetBooksByGenre(genre.GenreId).OrderBy(p => p.Title);
            }
            else
            {
                books = _bookRepository.GetBooks.ToList();
            }

            currentGanre = genre.GenreName;


            return(View(new BookViewModel
            {
                Books = books,
                CurrentGanre = currentGanre
            }));
        }
Ejemplo n.º 2
0
        public ViewResult List(int genreId)
        {
            List <string>      _genres = new List <string>();;
            IEnumerable <Book> books;
            string             currentGenre = string.Empty;


            var genre = _genre.GenreByCategory(genreId);;

            if (genreId != 0)
            {
                books        = _book.GetBooksByGenre(genre.GenreId).OrderBy(p => p.Title).ToList();
                currentGenre = genre.GenreName;
            }
            else
            {
                books        = _book.GetBooks.ToList();
                currentGenre = "All books";
            }

            return(View(new HomeIndexVM
            {
                Books = books,
                CurrentGenre = currentGenre
            }));
        }