Created
August 31, 2020 14:05
-
-
Save CoskunKurtuldu/89b3eb7e9f4b7c554eef0e2176a3f15c to your computer and use it in GitHub Desktop.
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
[HttpPost("Roles")] | |
public async Task<IActionResult> CreateRole(string roleName) | |
{ | |
if(string.IsNullOrWhiteSpace(roleName)) | |
{ | |
return BadRequest("Role name should be provided."); | |
} | |
var newRole = new Role | |
{ | |
Name = roleName | |
}; | |
var roleResult = await _roleManager.CreateAsync(newRole); | |
if (roleResult.Succeeded) | |
{ | |
return Ok(); | |
} | |
return Problem(roleResult.Errors.First().Description, null, 500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment