Created
August 31, 2020 14:06
-
-
Save CoskunKurtuldu/1ccd4785a9d6a40ed9388d0b7f1baca6 to your computer and use it in GitHub Desktop.
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("User/{userEmail}/Role")] | |
public async Task<IActionResult> AddUserToRole(string userEmail, [FromBody] string roleName) | |
{ | |
var user = _userManager.Users.SingleOrDefault(u => u.UserName == userEmail); | |
var result = await _userManager.AddToRoleAsync(user, roleName); | |
if (result.Succeeded) | |
{ | |
return Ok(); | |
} | |
return Problem(result.Errors.First().Description, null, 500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment