Last active
September 24, 2019 21:41
-
-
Save wellingtonjhn/8bbda8cfc60c7dee8f4ccfd49efbe6a8 to your computer and use it in GitHub Desktop.
Controller with MediatR command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Route("api/[controller]")] | |
| [ApiController] | |
| public class CustomersController : ControllerBase | |
| { | |
| private readonly IMediator _mediator; | |
| public CustomersController(IMediator mediator) | |
| { | |
| _mediator = mediator; | |
| } | |
| [HttpPost] | |
| public async Task<IActionResult> Post([FromBody] CreateCustomer command) | |
| { | |
| var id = await _mediator.Send(command); | |
| return Created($"api/customers/{id}", id); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment