public JsonResult GetComments(int id) { BLLComments Bll = new BLLComments(); var CommList = Bll.GetDataByPostID(id); return(Json(new { data = CommList }, JsonRequestBehavior.DenyGet)); }
public JsonResult CreateComments(int newsId, int parentId, string comment) { int userId = -1; if (Session["UserId"] != null) { userId = int.Parse(Session["UserID"].ToString()); } string userName = ""; if (Session["UserName"] != null) { userName = Session["UserName"].ToString(); } BLLComments bllCom = new BLLComments(); CommentsInfo commentsInfo = new CommentsInfo { CommentDate = DateTime.Now, Comment = comment, ParentCommentID = parentId, Ip = Request.UserHostAddress, PostID = newsId, UserName = userName, UserId = userId }; //添加评论 bllCom.Insert(commentsInfo); //查询评论 var CommentList = bllCom.GetDataByPostID(newsId); return(Json(new { data = CommentList }, JsonRequestBehavior.DenyGet)); }