예제 #1
0
        //新增/编辑文章页面
        public ActionResult AddOrEditChapter(string id)
        {
            string pageNum = Request["pagenum"];

            ViewBag.PageNum = pageNum == null ? 1 : Convert.ToInt32(pageNum);
            if (!WebHelper.CheckLogin())  //判断登录
            {
                string url = string.Format("/UserOperation/Login?returnUrl=/{0}", "AddOrEditChapter?id=" + id);
                //return Redirect(url);
            }

            ChapterBLL chapterBll = new ChapterBLL();
            Chapter    chapter    = new Chapter();

            if (string.IsNullOrEmpty(id))  //新增
            {
                return(View(new Chapter()));
            }
            else   //编辑
            {
                int chapterId = Convert.ToInt32(id);
                int userId    = (int)WebHelper.GetUserIdInSession();
                chapter = chapterBll.GetByChapterId(chapterId);
                if (chapter != null && chapter.Id > 0 && chapter.UserId == userId)
                {
                    return(View(chapter));
                }
                return(View(new Chapter()));
            }
        }
예제 #2
0
        //获取文章的踩/赞数
        public JsonResult GetCaiZanCount()
        {
            int        caiCount   = 0;
            int        zanCount   = 0;
            int        chapterId  = Convert.ToInt32(Request["chapterId"]);
            ChapterBLL chapterBll = new ChapterBLL();
            Chapter    chapter    = chapterBll.GetByChapterId(chapterId);

            caiCount = chapter.CaiCount;
            zanCount = chapter.ZanCount;
            return(Json(new { CaiCount = caiCount, ZanCount = zanCount }, JsonRequestBehavior.AllowGet));
        }