Skip to content

Instantly share code, notes, and snippets.

@wellingtonjhn
Last active April 9, 2018 03:55
Show Gist options
  • Select an option

  • Save wellingtonjhn/0dec296770cf381b803e5c48852f3f72 to your computer and use it in GitHub Desktop.

Select an option

Save wellingtonjhn/0dec296770cf381b803e5c48852f3f72 to your computer and use it in GitHub Desktop.
ASP.Net Core Controller - MediatR
[Route("api/[controller]")]
public class AccountsController : Controller
{
private readonly IMediator _mediator;
public AccountsController(IMediator mediator)
{
_mediator = mediator;
}
[HttpPost]
public async Task<IActionResult> CreateUser([FromBody] CreateUser command)
{
var response = await _mediator.Send(command).ConfigureAwait(false);
if (response.Errors.Any())
{
return BadRequest(response.Errors);
}
return Ok(response.Result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment