public bool Write(string commentToShow) { error.Clear(); //validate //user if (!CurrentUser.isLoggedIn) { return(error.SetErrorAndReturnFalse(ErrorCode.INVALID_SESSION)); } if (!InputValidator.ValidateId(CurrentUser.id)) { return(error.SetErrorAndReturnFalse(ErrorCode.USER_NOT_FOUND)); } //good text if (!InputValidator.ValidateForumProblemCommentText(commentToShow)) { return(error.SetErrorAndReturnFalse(ErrorCode.INVALID_TEXT_FIELD | InputValidator.error.no)); } //valid as comment //first get timestamp long unix = DataFetcher.GetServerTimeStamp(); Comment comment = new Comment(0, CurrentUser.id, forumPost.id, commentToShow, unix); //push if (!UserDataPusher.PushNewForumProblemComment(comment)) { return(error.SetErrorAndReturnFalse(ErrorCode.PUSH_ERROR)); } //retrieve id this.lastComment = DataFetcher.GetCommentFromTemplate(comment); //changes only id comments.Add(this.lastComment); //this.LoadLast(this.commentsPanel); if (SuccessfullyAddedCommentEvent != null) { SuccessfullyAddedCommentEvent.Invoke(this, new SuccessfullyAddedCommentEventArgs(commentToShow, unix)); //invokes event if it has subscribers } return(true); }