Beispiel #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);
        }