Exemplo n.º 1
0
        public ActionResult Index(HomeShowType showType = HomeShowType.Category, int?id = null)
        {
            // Load for navigation UI.
            ViewBag.CategoryNames = categoryBU.GetList();
            ViewBag.AuthorNames   = authorBU.GetList();

            // Load model for the view.
            if (id == null)
            {
                switch (showType)
                {
                case HomeShowType.Category:
                    id = categoryBU.GetFirst().CateId;
                    break;

                case HomeShowType.Author:
                    id = authorBU.GetFirst().AuthorId;
                    break;

                default:
                    break;
                }
            }
            var books = bookBU.GetListBy(showType, id.Value);

            return(View(books));
        }
Exemplo n.º 2
0
        public List <Book> GetListBy(HomeShowType showType, int id)
        {
            switch (showType)
            {
            case HomeShowType.Category:
                return(bookDA.GetListByCategory(id));

            case HomeShowType.Author:
                return(bookDA.GetListByAuthor(id));

            default:
                return(null);
            }
        }