Example #1
0
        public ServiceResponse Commenting(int blogId, CommentPostInDto input)
        {
            var post = _postRepository.Get()
                       .Where(x => x.Id == input.BlogId)
                       .Include(x => x.Comments)
                       .FirstOrDefault();
            var user = GetAuthenticatedUser();

            if (user.IsAuthenticated)
            {
                post.AddComment(input.Content, user.UserId, user.UserName);
                _postRepository.Complete();
                s_diagnosticListener.WriteAddPostCommentAfter(post.Id);
                return(ServiceResponse.OK());
            }
            return(ServiceResponse.Unauthorized());
        }