//网数据库中写入一本书
 public static void WriteBook(int urlId, string name, int startIndex, int endIndex)
 {
     JY_Book b = new JY_Book();
     b.Name = name;
     JYBookDao dao = new JYBookDao();
     int result = dao.add(b);
     dao.Dispose();
     if (result <= 0)
         throw new ApplicationException("插入book错误!");
     for (int i = 1; i <= (endIndex - startIndex + 1); i++)
         WriteArticle(b.Id, urlId, startIndex + i - 1, i);
 }
 //首页
 public ActionResult Index()
 {
     //排序规则
     ViewBag.sequnce = "飞雪连天射白鹿笑书神侠倚碧鸳";
     List<JY_Book> allBook = null;
     using (JYBookDao dao = new JYBookDao())
         allBook = dao.getAll();
     string content = "";
     foreach (string item in allBook.Select(t => t.Name))
         content += (item + "、");
     content = content.Substring(0, content.Length - 1);
     ViewBag.content = content;
     return View(allBook);
 }
 //书籍详情
 public ActionResult Book(int id)
 {
     //书籍信息
     JY_Book b = null;
     List<CatalogItem> catalog = null;
     using (JYBookDao dao = new JYBookDao())
     {
         b = dao.get(id);
         catalog = dao.getCatalog(id);
     }
     if (b == null)
         throw new ApplicationException("找不到书籍");
     //书籍目录
     ViewBag.catalog = catalog;
     ViewBag.firstArticleId = catalog.First().Id;
     return View(b);
 }