コード例 #1
0
ファイル: HomeController.cs プロジェクト: the404/yqblog
        public ActionResult AjaxComment(CommentModel model)
        {
            if (Configinfo.UserPermission && UserInfo==null)
            {
                return JsonReturn("error.userpermission", string.Empty, string.Empty);
            }

            if (ModelState.IsValid)
            {
                if (Configinfo.IfValidateCode && model.ValidationCode != HttpContext.Session["validationCode"].ToString())
                {
                    return JsonReturn("error.validationcode", string.Empty, string.Empty);
                }

                if (UserInfo != null && (model.CommentId > 0 && UserInfo.userid == model.UserId))
                {
                    var item = MyService.GetArticleById(model.CommentId);
                    item.title = model.Email.ExReturnNotNull().ExRemoveHtml();
                    item.summary = model.Url.ExReturnNotNull().ExRemoveHtml();
                    item.content = WebUtils.FileterData(model.Content, model.DataType);
                    MyService.UpdateArticle(item);
                    return JsonReturn(string.Empty, string.Empty, item.orderid.ToString());
                }

                if (model.CommentId==0)
                {
                    var obj = InitialArticleModel.VArticle();
                    var article = MyService.GetArticleById(model.CommentArticleId);
                    obj.title = model.Email.ExReturnNotNull().ExRemoveHtml();
                    obj.summary = model.Url.ExReturnNotNull().ExRemoveHtml();
                    obj.content = WebUtils.FileterData(model.Content, model.DataType);
                    obj.articleid = model.CommentArticleId;
                    obj.layer = 1;
                    obj.parentid = model.ParentId;
                    obj.userid = model.UserId;
                    obj.username = model.UserName.Trim();
                    obj.typeid = article.typeid;
                    obj.cateid = article.cateid;
                    var re = MyService.AddArticle(obj);
                    var newComment = MyService.GetArticleById(re);
                    SendCommentReplyEmail(newComment);
                    return JsonReturn(string.Empty, string.Empty, newComment.orderid.ToString());
                }
            }
            return JsonReturn("error.modelvalid", string.Empty, string.Empty);
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: the404/yqblog
        public ActionResult AjaxCommentForm()
        {
            var comment = new CommentModel
                                       {
                                           CommentId = 0,
                                           DataType = 1,
                                           UserId = UserInfo == null ? 0 : UserInfo.userid,
                                           UserName = UserInfo == null ? string.Empty : UserInfo.username
                                       };

            return PartialView("_Comment", comment);
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: the404/yqblog
 public ActionResult Reply(int id)
 {
     ViewBag.CI = Configinfo;
     var comment = new CommentModel();
     var article = MyService.GetVArticleById(id);
     var category = MyService.GetCategoryById(article.cateid);
     comment.CommentArticleId = id;
     if (category.ReplyPermit == 1 && article.replypermit == 1)
     {   comment.ReplyPermit = 1;}
     else
     {   comment.ReplyPermit = 0;}
     return PartialView("_Comment", comment);
 }
コード例 #4
0
ファイル: HomeController.cs プロジェクト: the404/yqblog
 public ActionResult GetOneComment(long id)
 {
     var article = MyService.GetArticleById(id);
     var comment = new CommentModel
     {
         CommentArticleId = article.articleid,
         CommentId = id,
         UserId = article.userid,
         UserName = article.username.Trim(),
         Email = article.title.Trim(),
         Url = article.summary.Trim(),
         Content = article.content
     };
     return Json(comment, "text/html;charset=UTF-8");
 }