Created
April 29, 2018 08:24
-
-
Save wellingtonjhn/5b5ff3a0d20928b21334445f663c57f3 to your computer and use it in GitHub Desktop.
AuthController - MediatR
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]")] | |
| public class AuthController : Controller | |
| { | |
| private readonly IMediator _mediator; | |
| public AuthController(IMediator mediator) | |
| { | |
| _mediator = mediator; | |
| } | |
| [HttpPost, AllowAnonymous, Route("login")] | |
| public async Task<IActionResult> Authenticate([FromBody] AuthenticateUser command) | |
| { | |
| var response = await _mediator.Send(command); | |
| if (response.HasMessages) | |
| { | |
| return BadRequest(response.Messages); | |
| } | |
| return Ok(response.Value); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment