//回覆文章 / 回覆回覆 public ActionResult Reply(CNewReplyCreate replyInfo) { string status = ""; //TODO //從Session讀取資料 //判斷是否有登入,如果有登入,取得該會員的fId CReply reply = new CReply(); if (replyInfo.targetType == "POST") { reply.NewCommentForPost(replyInfo, 5); } if (replyInfo.targetType == "COMMENT") { reply.NewCommentForComment(replyInfo, 5); } return(Content(status)); }
//呈現文章的內容 public ActionResult PostView(int fPostId) { //一進入Action就先取出當下時間 ViewBag.DateTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"); CForum forum = new CForum(); tForum tForum = forum.queryPostById(fPostId); CReply reply = new CReply(); List <List <tForumReply> > replys = reply.getReplysById(fPostId); CPostView postview = new CPostView { forum = tForum, reply = replys }; if (postview.forum != null) { string test = postview.forum.fPostContent; return(View(postview)); } return(RedirectToAction("List")); }
//定時更新留言List public ActionResult RefreshReplyList(int lastPostId, string prevDtaetime) { //一進入Action就先取出當下時間 string newTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"); //撈出更新時間在prevDateTime之後的所有留言 DateTime targetTime = DateTime.ParseExact(prevDtaetime, "yyyyMMddHHmmssfff", CultureInfo.CurrentCulture); CReply reply = new CReply(); List <tForumReply> replys = reply.getNewReplysByTime(lastPostId, targetTime); List <object> newReplyList = new List <object>(); if (replys.Count > 0) { foreach (var item in replys) { var newReply = new { replyId = item.fReplyId, //自己的ID replyTargetId = item.fReplyTargetId, //回覆對象的ID replySeqNo = item.fReplySeqNo, replyContent = item.fContent }; newReplyList.Add(newReply); } } return(Json( new { newTime = newTime, newReplyList = newReplyList }, JsonRequestBehavior.AllowGet)); }