public HttpResponseMessage SubmitPost(HttpRequestMessage request, [FromBody] BlogPost blogPost) { HttpResponseMessage response = null; try { blogPost.Timestamp = DateTime.Now; PreSubmissionPostingEventArgs preArgs = new PreSubmissionPostingEventArgs(blogPost); _ExtensibilityManager.InvokeCancelableModuleEvent <PreSubmissionPostingEventArgs>( _ModuleEvents.PreSubmissionPosting, preArgs); if (!preArgs.Cancel) { IBlogPostRepository blogPostRepository = _componentLocator.ResolveComponent <IBlogPostRepository>(); blogPost = blogPostRepository.Add(blogPost); PostSubmissionPostingEventArgs postArgs = new PostSubmissionPostingEventArgs(blogPost); _ExtensibilityManager.InvokeModuleEvent <PostSubmissionPostingEventArgs>( _ModuleEvents.PostSubmissionPosting, postArgs); response = request.CreateResponse <BlogPost>(HttpStatusCode.OK, blogPost); } } catch (Exception ex) { response = request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex); } return(response); }
void OnPreSubmissionPosting(PreSubmissionPostingEventArgs e) { string header = string.Empty; StringBuilder footer = new StringBuilder(); footer.AppendLine(); footer.AppendLine("---------------------------------"); footer.AppendLine("Available Pluralsight courses:"); footer.AppendLine(" Building End-to-End Multi-Client Service Oriented Applications"); footer.AppendLine(" Building End-to-End Multi-Client Service Oriented Applications - angular edition"); footer.AppendLine(" Developing Extensible Software"); footer.AppendLine(" WCF End-to-End"); footer.AppendLine(" WCF Power Topics"); footer.AppendLine(); e.BlogPost.PostBody += footer.ToString(); }
void OnPreSubmissionPosting(PreSubmissionPostingEventArgs e) { // since postings are done by admin, no sense using another "replacement" property e.BlogPost.PostSubject = ReplaceProfanity(e.BlogPost.PostSubject); e.BlogPost.PostBody = ReplaceProfanity(e.BlogPost.PostBody); }