private static int PostOrEdit(string text, string bbuid, int?postID, uint topicID, string postSubject) { Spring db = new Spring(new MySqlConnection(ConfigurationManager.AppSettings["SpringConnectionString"])); PhPbB3Posts post; if (postID != null && postID.Value != 0 && (post = db.PhPbB3Posts.Where(x => x.PostID == postID).SingleOrDefault()) != null) { post.PostText = text; post.BbcOdeUID = bbuid; post.PostSubject = postSubject; db.SubmitChanges(); return(postID.Value); } else { uint time = ToUnix(DateTime.UtcNow); post = new PhPbB3Posts(); post.ForumID = ForumId; post.PosterID = PosterId; post.PostSubject = postSubject; post.BbcOdeBitField = Bbbitcode; post.BbcOdeUID = bbuid; post.TopicID = topicID; post.PostTime = time; post.PostText = text; post.PosterIP = PosterIp; post.PostEditReason = ""; post.PostChecksum = ""; post.PostApproved = 1; post.EnableBbcOde = 1; post.EnableSmILies = 1; post.EnableMagicURL = 1; post.PostUserName = ""; db.PhPbB3Posts.InsertOnSubmit(post); db.SubmitChanges(); PhPbB3Topics topic = db.PhPbB3Topics.Where(x => x.TopicID == post.TopicID).Single(); topic.TopicLastPostID = post.PostID; topic.TopicLastPostTime = time; topic.TopicRepliesReal++; topic.TopicReplies++; db.SubmitChanges(); return((int)post.PostID); } }
private static int PostOrEdit(string text, string bbuid, int? postID, uint topicID, string postSubject) { Spring db = new Spring(new MySqlConnection(ConfigurationManager.AppSettings["SpringConnectionString"])); PhPbB3Posts post; if (postID != null && postID.Value != 0 && (post = db.PhPbB3Posts.Where(x => x.PostID == postID).SingleOrDefault()) != null) { post.PostText = text; post.BbcOdeUID = bbuid; post.PostSubject = postSubject; db.SubmitChanges(); return postID.Value; } else { uint time = ToUnix(DateTime.UtcNow); post = new PhPbB3Posts(); post.ForumID = ForumId; post.PosterID = PosterId; post.PostSubject = postSubject; post.BbcOdeBitField = Bbbitcode; post.BbcOdeUID = bbuid; post.TopicID = topicID; post.PostTime = time; post.PostText = text; post.PosterIP = PosterIp; post.PostEditReason = ""; post.PostChecksum = ""; post.PostApproved = 1; post.EnableBbcOde = 1; post.EnableSmILies = 1; post.EnableMagicURL = 1; post.PostUserName = ""; db.PhPbB3Posts.InsertOnSubmit(post); db.SubmitChanges(); PhPbB3Topics topic = db.PhPbB3Topics.Where(x => x.TopicID == post.TopicID).Single(); topic.TopicLastPostID = post.PostID; topic.TopicLastPostTime = time; topic.TopicRepliesReal++; topic.TopicReplies++; db.SubmitChanges(); return (int) post.PostID; } }