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)); }
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); } }