/// <summary> /// 更新完成的页数 /// </summary> /// <param name="bookid"></param> public static void UpdateDonePage(int bookid) { try { Inpinke_Book model = GetBookByID(bookid); IList <Inpinke_Book_Page> list = GetBookPage(bookid); int donePage = 0; if (list != null) { foreach (Inpinke_Book_Page p in list) { if (p.PageNum == 0) { continue; } if (p.IsSkip) { donePage += 2; } else { donePage++; } } model.DonePages = donePage; } model.SaveWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); } catch (Exception ex) { Logger.Error(string.Format("UpdateDonePage BookID:{0}, Error:{1}", bookid, ex.ToString())); } }
/// <summary> /// 增加页面 /// </summary> /// <param name="bookid"></param> /// <param name="userid"></param> /// <param name="pagecount"></param> /// <returns></returns> public ActionResult AddBookPage(int bookid, int userid, int pagecount) { try { Inpinke_Book book = DBBookBLL.GetBookByID(bookid); if (book == null) { return(Content("{\"success\":false,\"msg\":\"添加书本页面失败,刷新页面再试试吧!\"}")); } if (book.PageCount >= pagecount) { return(Content("{\"success\":false,\"msg\":\"添加书本页面失败,刷新页面再试试吧!\"}")); } Inpinke_Book_Page bookpage = DBBookBLL.GetBookPageByPNum(book.PageCount, bookid); if (bookpage != null) { bookpage.PageData.SetAttributeValue("opnum", book.PageCount + "_" + (book.PageCount + 1)); bookpage.PageData = XElement.Parse(bookpage.PageData.ToString()); bookpage.SaveWhenSubmit(InpinkeDataContext.Instance); } book.PageCount = pagecount; book.SaveWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); return(Content("{\"success\":true,\"msg\":\"添加书本页面成功!\"}")); } catch (Exception ex) { Logger.Error(string.Format("AddBookPage Error:{0},BookID:{1},UserID:{2},PageCount:{3}", ex.ToString(), bookid, userid, pagecount)); return(Content("{\"success\":false,\"msg\":\"添加书本页面失败,刷新页面再试试吧!\"}")); } }
/// <summary> /// 更新书本信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static BaseResponse UpdateBook(Inpinke_Book model) { BaseResponse br = new BaseResponse(); br.IsSuccess = false; try { model.UpdateTime = DateTime.Now; model.SaveWhenSubmit(InpinkeDataContext.Instance); InpinkeDataContext.Instance.Submit(); br.IsSuccess = true; br.Message = "书本信息更新成功"; } catch (Exception ex) { br.IsSuccess = false; br.Message = "书本信息更新失败,请稍后再试"; Logger.Error(string.Format("UpdateBook Error:{0},BookID:{1}", ex.ToString(), model.ID)); } return(br); }