public IActionResult Post(int id, [FromBody] string value)
        {
            _logger.LogInformation("Validation and post value request");

            if (id < 0)
            {
                return(BadRequest(ApiResponse.Error(new[] { new ApiResponseError {
                                                                Code = "01", Title = "Id shouldn't be negative"
                                                            } })));
            }

            _commandsDispatcher.Execute(new SetValueCommandContext(id, value));
            return(Ok(ApiResponse.Success(id)));
        }
Exemplo n.º 2
0
        public IActionResult Post(int id, [FromBody] string value)
        {
            _logger.LogInformation("Validation and post value request");

            if (id < 0)
            {
                return new ObjectResult(ApiResponse.Error(new[] { new ApiResponseError {
                                                                      Code = "01", Title = "Id shouldn't be negative"
                                                                  } }))
                       {
                           StatusCode   = (int)HttpStatusCode.BadRequest,
                           DeclaredType = typeof(ApiResponse <object>)
                       }
            }
            ;

            _commandsDispatcher.Execute(new SetValueCommandContext(id, value));
            return(new OkObjectResult(ApiResponse.Success(id))
            {
                DeclaredType = typeof(ApiResponse <int>)
            });
        }
 public void Post(int id, [FromBody] string value)
 {
     _logger.LogInformation("Validation and post value request");
     _commandsDispatcher.Execute(new SetValueCommandContext(id, value));
 }