void OnPreSubmissionComment(PreSubmissionCommentEventArgs e) { if (_BannedUsers.Contains(e.BlogComment.Email.ToLower())) { e.Cancel = true; } }
void OnPreSubmissionComment(PreSubmissionCommentEventArgs e) { // read email configuration from the config file if (e.BlogComment.CommentBody != e.CommentReplacement) { // send email with comment info, including replacement comment Trace.WriteLine( string.Format("Posting alert: Comment '{0}' was replaced with '{1}'.", e.BlogComment.CommentBody, e.CommentReplacement)); } else { // send email with comment info, including replacement comment System.Diagnostics.Debug.WriteLine( string.Format("Posting info: Comment '{0}' was posted as-is'.", e.BlogComment.CommentBody)); } }
public HttpResponseMessage SubmitComment(HttpRequestMessage request, [FromBody] BlogComment blogComment) { HttpResponseMessage response = null; try { blogComment.Timestamp = DateTime.Now; PreSubmissionCommentEventArgs preArgs = new PreSubmissionCommentEventArgs(blogComment); _ExtensibilityManager.InvokeCancelableModuleEvent <PreSubmissionCommentEventArgs>( _ModuleEvents.PreSubmissionComment, preArgs); if (!preArgs.Cancel) { IBlogCommentRepository blogCommentRepository = _componentLocator.ResolveComponent <IBlogCommentRepository>(); blogComment.CommentBody = preArgs.CommentReplacement; blogComment = blogCommentRepository.Add(blogComment); PostSubmissionCommentEventArgs postArgs = new PostSubmissionCommentEventArgs(blogComment); _ExtensibilityManager.InvokeModuleEvent <PostSubmissionCommentEventArgs>( _ModuleEvents.PostSubmissionComment, postArgs); response = request.CreateResponse <BlogComment>(HttpStatusCode.OK, blogComment); } else { throw new ApplicationException("Comment submission has been blocked."); } } catch (Exception ex) { response = request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex); } return(response); }
void OnPreSubmissionComment(PreSubmissionCommentEventArgs e) { // "replacement" property allows another module to communicate before & after to admin e.CommentReplacement = ReplaceProfanity(e.BlogComment.CommentBody); }