Exemplo n.º 1
0
        public async Task <ActionResult> Post(int post, [FromBody] CommentCreateCommand command)
        {
            if (post != command.Id_Post)
            {
                return(NotFound());
            }

            var result = await m_commandResolver.Publish <CommentCreateCommand, CommentCreateResult>(command);

            if (result.Exception != null)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }

            if (result.ValidationErrors.Any())
            {
                return(BadRequest(result.ValidationErrors));
            }

            return(CreatedAtAction(nameof(Get), new { post, id = result.Created }, result));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Post([FromBody] PostCreateCommand command)
        {
            var result = await m_commandResolver.Publish <PostCreateCommand, PostCreateResult>(command);

            return(CreateOrEditResult(result.Created, result));
        }
Exemplo n.º 3
0
 public CommentCreateResult CreateComment(Post post, CommentCreateCommand command)
 {
     return(m_resolver.Publish <CommentCreateCommand, CommentCreateResult>(command).Result);
 }