Exemple #1
0
        public ViewResult Books(string filter)
        {
            CatalogViewModel obj = new CatalogViewModel();

            if (string.IsNullOrEmpty(filter))
            {
                obj.Books   = _books.AllBooks;
                obj.Genres  = _booksGenre.AllGenres;
                obj.Authors = _booksAuthor.AllAuthors;
            }

            else
            {
                if (string.Equals("Favorite", filter, StringComparison.OrdinalIgnoreCase))
                {
                    obj.Books = _books.GetFavoriteBooks;
                }
                else if (string.Equals("New", filter, StringComparison.OrdinalIgnoreCase))
                {
                    obj.Books = _books.GetNewBooks;
                }
                else if (string.Equals("Stock", filter, StringComparison.OrdinalIgnoreCase))
                {
                    obj.Books = _books.GetStockBooks;
                }
                obj.Genres  = _booksGenre.Genres(obj.Books);
                obj.Authors = _booksAuthor.Authors(obj.Books);
            }
            return(View(obj));
        }