public static int CreatePost(int tenantID, int topicID, int parentPostID, string subject, string text, bool isApprove, PostTextFormatter formatter) { int postID; using (var tr = DbManager.Connection.BeginTransaction(IsolationLevel.ReadUncommitted)) { postID = DbManager.ExecuteScalar<int>(new SqlInsert("forum_post") .InColumnValue("id", 0) .InColumnValue("TenantID", tenantID) .InColumnValue("topic_id", topicID) .InColumnValue("create_date", DateTime.UtcNow) .InColumnValue("subject", subject) .InColumnValue("text", text) .InColumnValue("poster_id", SecurityContext.CurrentAccount.ID) .InColumnValue("is_approved", isApprove ? 1 : 0) .InColumnValue("parent_post_id", parentPostID) .InColumnValue("formatter", (int)formatter) .Identity(0, 0, true)); var threadID = DbManager.Connection.CreateCommand("select thread_id from forum_topic where id=@topicID and TenantID = @tid") .AddParameter("topicID", topicID).AddParameter("tid", tenantID).ExecuteScalar<int>(); UpdateTopicThread(tenantID, topicID, threadID); tr.Commit(); } return postID; }
public static void UpdatePost(int tenantID, int postID, string subject, string text, PostTextFormatter formatter) { DbManager.Connection.CreateCommand(@"update forum_post set text = @text, subject = @subject, formatter = @formatter, edit_count = edit_count+1, edit_date = @date, editor_id = @euid where id = @postID and TenantID = @tid") .AddParameter("text", text) .AddParameter("subject", subject) .AddParameter("formatter", (int)formatter) .AddParameter("date", DateTime.UtcNow) .AddParameter("euid", SecurityContext.CurrentAccount.ID) .AddParameter("postID", postID) .AddParameter("tid", tenantID).ExecuteNonQuery(); }