Example #1
0
        public ActionResult Index()
        {
            BoardViewModel model = new BoardViewModel();

            model.SiteID = BlogID;
            Blogs.Entity.blog_tb_blog blog = Utility.BlogBll.GetEntity(base.BlogID);
            model.IsCloseBoard = blog.IsCloseBoard;

            model.Title = "留言板-" + Info.blogTitle;

            int state = 1;

            if (HasPermission)
            {
                state = -1;
            }

            model.Collection = Utility.BoardBll.Query(state);

            return(View("~/Views/Board/V1/Index.cshtml", model));
        }
        public ActionResult Comment()
        {
            string commentContent = Request["commentContent"];
            string articleID      = Request["articleID"];

            if (string.IsNullOrEmpty(commentContent))
            {
                return(Json(new { code = -1, message = "请输入回复内容!" }, JsonRequestBehavior.AllowGet));
            }

            Blogs.Entity.blog_tb_blog blog = Utility.BlogBll.GetEntity(base.BlogID);
            if (blog.IsCloseComment)
            {
                return(Json(new { code = -999, message = "系统已经关闭评论!" }, JsonRequestBehavior.AllowGet));
            }

            if (!Utility.CommentBll.IsAllowCommentContent(commentContent))
            {
                return(Json(new { code = -1, message = "输入的内容有危险性!" }, JsonRequestBehavior.AllowGet));
            }


            DateTime?lastDate = null;

            if (Session["lastDate"] != null)
            {
                lastDate = Convert.ToDateTime(Session["lastDate"]);
            }

            int    articleCommentLimit = Utility.ArticleBll.GetArticleCommentLimit(articleID);
            string articleUserID       = Utility.ArticleBll.GetarticleUserID(articleID);

            if (Utility.CommentBll.isDisableComment(articleCommentLimit) && !isOwner(articleUserID))
            {
                return(Json(new { code = -4, message = "该文章禁止回复!" }, JsonRequestBehavior.AllowGet));
            }

            if (Utility.CommentBll.isDisabledAnonymousComment(articleCommentLimit) && !isOwner(articleUserID))
            {
                return(Json(new { code = -5, message = "该文章不允许匿名回复,请登录后回复!" }, JsonRequestBehavior.AllowGet));
            }
            if (isOwner(articleUserID) || lastDate == null || (DateTime.Now.Subtract(lastDate.Value).TotalSeconds > 60))
            {
                Blogs.Entity.blog_tb_comment model = new Entity.blog_tb_comment();
                model.commentContent = commentContent;  //html过滤

                //非自己回复需要审核
                if (!isOwner(articleUserID))
                {
                    model.commentState = 0;
                }

                int floor = Utility.CommentBll.GetMaxFloor(articleID);

                model.commentIP = Utility.GetClientIP(HttpContext);


                model.floor       = floor + 1;
                model.commentText = Request["commentText"];
                model.articleID   = Convert.ToInt32(articleID);
                model.userID      = Utility.UserID;
                model.userName    = Utility.UserName;
                Utility.CommentBll.Insert(model);
                Session["lastDate"] = DateTime.Now;
                string message = "发布成功";
                if (Utility.CommentBll.isVerifyComment(articleCommentLimit))
                {
                    message = "发布成功,需要审核后才会显示";
                }
                return(Json(new { code = 1, message = message }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { code = -3, message = (60 - (int)(DateTime.Now.Subtract(lastDate.Value).TotalSeconds) + "秒内不能重复回复!") }, JsonRequestBehavior.AllowGet));
            }
        }