public JsonResult Reply(int pid, string content) { var m = new ReplyMode() { pid = pid, content = Functions.FilterXSS(content) }; TryValidateModel(m); if (ModelState.IsValid) { using (Db db = Db.table("reply"), db1 = Db.table("post")) { using (var data = db1.where ("pid", pid).find()) { if (!data.HasRows) { return(Json(new ErrorJsonModel(-1, "帖子不存在"))); } //加入记录 var replyData = new Dictionary <string, object>(); replyData.Add("reply_uid", ViewData["uid"]); replyData.Add("reply_pid", m.pid); replyData.Add("reply_content", m.content); replyData.Add("reply_time", Functions.timestamp()); db.insert(replyData); } } return(Json(new ErrorJsonModel(0, "回帖成功"))); } return(Json(new ErrorJsonModel(-1, Functions.getErrorMsg(ModelState)))); }
/// <summary> /// Replies to the message by posting to the same user/channel where the Message originated /// </summary> /// <param name="replyText">Text to reply with.</param> /// <param name="forcePrivate">Should the message be sent as private regardless of parent message origin?</param> internal void Reply(string replyText, ReplyMode ReplyMode = ReplyMode.AsOriginal) { Message reply = new Message(replyText, this); switch (ReplyMode) { case ReplyMode.AsOriginal: break; case ReplyMode.ForceChannel: if (reply.sourceChannel != null) { reply.OpCode = "MSG"; } break; case ReplyMode.ForcePM: reply.OpCode = "PRI"; break; } reply.Recipient = sourceUser; reply.Channel = sourceChannel != null ? sourceChannel.Key : null; reply.sourceUser = Core.OwnUser; reply.Send(); }
public PostPresenter(IPresenterHost host) { this.host = host; this.replyMode = ReplyMode.Inactive; }