Exemplo n.º 1
0
        public async Task <bool> Post(BlogPostCommentRequest request, IOutputPort <BlogPostCommentResponse> response)
        {
            if (request.BlogPostId <= 0)
            {
                response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Blog ID Is Not Null!") }));
                return(false);
            }
            if (string.IsNullOrWhiteSpace(request.Comment))
            {
                response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Blog Comment Is Not Null!") }));
                return(false);
            }
            if (request.CreateUser <= 0)
            {
                response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Failed To Get Session Information!") }));
                return(false);
            }
            var row = new BlgBlogPostComment()
            {
                BlgBlogPostId = request.BlogPostId,
                Comment       = request.Comment,
                CreateUser    = request.CreateUser,
                CreateDate    = request.CreateDate
            };

            repositories.BlgBlogPostCommentRepository.Create(row);
            await repositories.BlgBlogPostCommentRepository.SaveChangesAsync();

            response.Handle(new BlogPostCommentResponse(row, true));
            return(true);
        }
Exemplo n.º 2
0
 public BlogPostCommentResponse(BlgBlogPostComment comment, bool success = false, string message = null) : base(success, message)
 {
     BlgBlogPostComment = comment;
 }