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 async Task <bool> Delete(BlogPostCommentRequest request, IOutputPort <BlogPostCommentResponse> response)
        {
            if (request.BlogPostCommentId <= 0)
            {
                response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Comment ID Is Not Null!") }));
                return(false);
            }
            if (request.UpdateUser <= 0)
            {
                response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Failed To Get Session Information!") }));
                return(false);
            }
            var row = repositories.BlgBlogPostCommentRepository.FindByCondition(p => p.Id == request.BlogPostCommentId && !p.IsDeleted).Result;

            if (row == null)
            {
                response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Failed To Get Blog Post Information!") }));
                return(false);
            }
            row.IsDeleted  = true;
            row.UpdateUser = request.UpdateUser;
            row.UpdateDate = request.UpdateDate;
            repositories.BlgBlogPostCommentRepository.Update(row);
            await repositories.BlgBlogPostCommentRepository.SaveChangesAsync();

            response.Response(new BlogPostCommentResponse(true));
            return(true);
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Delete([FromBody] BlogPostCommentRequest request)
        {
            await blogPostCommentUseCase.Delete(new BlogPostCommentRequest()
            {
                BlogPostCommentId = request.BlogPostCommentId, UpdateUser = CurrentUserId(), UpdateDate = DateTime.Now
            }, blogPostCommentPresenter);

            return(blogPostCommentPresenter.ContentResult);
        }
Exemplo n.º 4
0
        public async Task <bool> Get(BlogPostCommentRequest request, IOutputPort <BlogPostCommentResponse> response)
        {
            if (request.BlogPostId <= 0)
            {
                response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Blog ID Is Not Null!") }));
                return(false);
            }
            var data = await repositories.BlgBlogPostCommentRepository.FindByCondition(p => p.Id == request.BlogPostCommentId);

            if (data != null)
            {
                response.Get(new BlogPostCommentResponse(data, true));
                return(true);
            }
            response.Handle(new BlogPostCommentResponse(new[] { new Error("error", "Is Not Load Blog Detail") }));
            return(false);
        }
Exemplo n.º 5
0
 public Task <bool> Handle(BlogPostCommentRequest message, IOutputPort <BlogPostCommentResponse> outputPort)
 {
     throw new System.NotImplementedException();
 }