public ActionResult ArtReplyMsg(int artreplyid, string artreplymsg) { JsonResult <string> result = new JsonResult <string>(); ArticleCommentServicese commnetServices = new ArticleCommentServicese(); if (artreplyid > 0) { article_comment add = new article_comment(); add.add_time = DateTime.Now; add.is_del = false; add.is_reply = false; add.content = artreplymsg; add.reply_id = null; add.article_id = artreplyid; if (commnetServices.Add(add) > 0) { result.Success(); } else { result.Fail("无法进行回复"); } } else { result.Fail("该文章不存在,无法回复"); } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 评论回复 /// </summary> /// <param name="msgid"></param> /// <param name="replymsg"></param> /// <returns></returns> public ActionResult ReplyMsg(int msgid, string replymsg) { JsonResult <string> result = new JsonResult <string>(); ArticleCommentServicese commnetServices = new ArticleCommentServicese(); var msg = commnetServices.query.Where(q => q.id == msgid).Where(q => q.is_del != true).FirstOrDefault(); if (msg != null) { article_comment add = new article_comment(); add.add_time = DateTime.Now; add.is_del = false; add.is_reply = true; add.content = replymsg; add.reply_id = msgid; add.article_id = msg.article_id; if (commnetServices.Add(add) > 0) { result.Success(); } else { result.Fail("无法进行回复"); } } else { result.Fail("该评论不存在,无法回复"); } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 文章评论列表 /// </summary> /// <param name="artid"></param> /// <param name="pageindex"></param> /// <param name="pagesize"></param> /// <returns></returns> public ActionResult ArtMessage(int artid, int pageindex, int pagesize) { ArticleCommentServicese commnetServices = new ArticleCommentServicese(); var result = commnetServices.query.Where(q => q.article_id == artid).Where(q => q.is_del != true).Where(q => q.is_reply != true).OrderBy(q => q.add_time).ToPagedList(pageindex, pagesize); ViewBag.pageindex = pageindex; return(PartialView(result)); }
/// <summary> /// 获取评论的回复列表 /// </summary> /// <param name="parentid"></param> /// <returns></returns> public static List <article_comment> GetRelpyMsg(int parentid) { ArticleCommentServicese commentservices = new ArticleCommentServicese(); return(commentservices.query.Where(q => q.is_del != true).Where(q => q.reply_id == parentid).OrderBy(q => q.add_time).ToList()); }