Last active
November 6, 2018 23:55
-
-
Save evgomes/ef071048d564cdfc261a9227bc553b98 to your computer and use it in GitHub Desktop.
Create user method from JWT API.
This file contains 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
[HttpPost] | |
public async Task<IActionResult> CreateUserAsync([FromBody] UserCredentialsResource userCredentials) | |
{ | |
if (!ModelState.IsValid) | |
{ | |
return BadRequest(ModelState); | |
} | |
var user = _mapper.Map<UserCredentialsResource, User>(userCredentials); | |
var response = await _userService.CreateUserAsync(user, ERole.Common); | |
if(!response.Success) | |
{ | |
return BadRequest(response.Message); | |
} | |
var userResource = _mapper.Map<User, UserResource>(response.User); | |
return Ok(userResource); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment