protected virtual PostDetails GetPostFromReader(IDataReader reader, bool readBody) { PostDetails post = new PostDetails( (int)reader["PostID"], (DateTime)reader["AddedDate"], reader["AddedBy"].ToString(), reader["AddedByIP"].ToString(), (int)reader["ForumID"], reader["ForumTitle"].ToString(), (int)reader["ParentPostID"], reader["Title"].ToString(), null, (bool)reader["Approved"], (bool)reader["Closed"], (int)reader["ViewCount"], (int)reader["ReplyCount"], (DateTime)reader["LastPostDate"], reader["LastPostBy"].ToString()); if (readBody) { post.Body = reader["Body"].ToString(); } return(post); }
public abstract int InsertPost(PostDetails post);
public abstract bool UpdatePost(PostDetails post);
/// <summary> /// Returns a Post object filled with the data taken from the input PostDetails /// </summary> private static Post GetPostFromPostDetails(PostDetails record) { if (record == null) return null; else { return new Post(record.ID, record.AddedDate, record.AddedBy, record.AddedByIP, record.ForumID, record.ForumTitle, record.ParentPostID, record.Title, record.Body, record.Approved, record.Closed, record.ViewCount, record.ReplyCount, record.LastPostBy, record.LastPostDate); } }
/// <summary> /// Updates an existing post /// </summary> public static bool UpdatePost(int id, string title, string body) { title = BizObject.ConvertNullToEmptyString(title); body = BizObject.ConvertNullToEmptyString(body); PostDetails record = new PostDetails(id, DateTime.Now, "", "", 0, "", 0, title, body, true, false, 0, 0, DateTime.Now, ""); bool ret = SiteProvider.Forums.UpdatePost(record); BizObject.PurgeCacheItems("forums_unapprovedposts"); BizObject.PurgeCacheItems("forums_threads"); BizObject.PurgeCacheItems("forums_threadcount"); BizObject.PurgeCacheItems("forums_thread_" + id.ToString()); BizObject.PurgeCacheItems("forums_post_" + id.ToString()); return ret; }
/// <summary> /// Creates a new post /// </summary> public static int InsertPost(int forumID, int parentPostID, string title, string body, bool closed) { title = BizObject.ConvertNullToEmptyString(title); body = BizObject.ConvertNullToEmptyString(body); // if the target forum is moderated, the current user must be an // admin, editor or moderator to insert the post in approved status bool approved = true; Forum forum = Forum.GetForumByID(forumID); if (forum.Moderated) { if (!BizObject.CurrentUser.IsInRole("Administrators") && !BizObject.CurrentUser.IsInRole("Editors") && !BizObject.CurrentUser.IsInRole("Moderators")) approved = false; } PostDetails record = new PostDetails(0, DateTime.Now, BizObject.CurrentUserName, BizObject.CurrentUserIP, forumID, "", parentPostID, title, body, approved, closed, 0, 0, DateTime.Now, BizObject.CurrentUserName); int ret = SiteProvider.Forums.InsertPost(record); if (approved) { BizObject.PurgeCacheItems("forums_threads"); BizObject.PurgeCacheItems("forums_thread_" + parentPostID.ToString()); BizObject.PurgeCacheItems("forums_threadcount"); } else BizObject.PurgeCacheItems("forums_unapprovedposts"); return ret; }
protected virtual PostDetails GetPostFromReader(IDataReader reader, bool readBody) { PostDetails post = new PostDetails( (int)reader["PostID"], (DateTime)reader["AddedDate"], reader["AddedBy"].ToString(), reader["AddedByIP"].ToString(), (int)reader["ForumID"], reader["ForumTitle"].ToString(), (int)reader["ParentPostID"], reader["Title"].ToString(), null, (bool)reader["Approved"], (bool)reader["Closed"], (int)reader["ViewCount"], (int)reader["ReplyCount"], (DateTime)reader["LastPostDate"], reader["LastPostBy"].ToString()); if (readBody) post.Body = reader["Body"].ToString(); return post; }