示例#1
0
        public static int CreateComment(int hostID, int storyID, User user, string comment)
        {
            if (user.IsBanned)
            {
                throw new SecurityException("A banned user can not post a comment");
            }

            if (comment.Length > 4000)
            {
                comment = comment.Substring(0, 4000);
            }

            Comment newComment = new Comment();

            newComment.HostID  = hostID;
            newComment.StoryID = storyID;
            newComment.UserID  = user.UserID;
            //TODO: GJ: rename comment as it is the same as the table name
            newComment.CommentX = comment;
            newComment.Save();

            StoryBR.IncrementStoryCommentCount(storyID);
            UserAction.RecordComment(hostID, user, Story.FetchByID(storyID), newComment.CommentID);
            return(newComment.CommentID);
        }
示例#2
0
        public static void Destroy(int storyID, int userID, int hostID, int tagID)
        {
            //NOTE: GJ: there is most likely a much better way of doing this with subsonic
            Query            query            = new Query(StoryUserHostTag.Schema).WHERE(StoryUserHostTag.Columns.StoryID, storyID).AND(StoryUserHostTag.Columns.UserID, userID).AND(StoryUserHostTag.Columns.HostID, hostID).AND(StoryUserHostTag.Columns.TagID, tagID);
            StoryUserHostTag storyUserHostTag = new StoryUserHostTag();

            storyUserHostTag.LoadAndCloseReader(StoryUserHostTag.FetchByQuery(query));
            StoryUserHostTag.Destroy(storyUserHostTag.StoryUserHostTagID);

            //update the story for the next crawl to pickup the change
            Story story = Story.FetchByID(storyID);

            story.UpdatedOn = DateTime.Now;
            story.Save();
        }
示例#3
0
 public static CommentCollection FetchCommentsByStoryID(int storyID)
 {
     return(Story.FetchByID(storyID).CommentRecords());
 }