public bool BlogCommentAdd(BlogComment model)
 {
     return(blogCommentRepository.Add(new BlogComment
     {
         BlogCommentId = model.BlogCommentId,
         BlogId = model.BlogId,
         UserId = model.UserId,
         Comment = model.Comment
     }));
 }
Beispiel #2
0
        public ActionResult Detail(BlogComment model)
        {
            BlogCommentRepository commentRepository = new BlogCommentRepository();

            commentRepository.Add(new RCP.Model.BlogComment
            {
                Content = model.Content,
                Title   = model.Title,
                BlogId  = model.BlogId,
                Blogs   = model.Blogs,

                Id           = model.Id,
                IsDelete     = false,
                RegisterDate = DateTime.Now
            });
            return(View());
        }
        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 = new BlogCommentRepository("easyBlog");

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