예제 #1
0
        public async Task <IActionResult> ApplyRoleAsync([Required] string id, [FromBody] ApplyRoleRq request)
        {
            var user = await _userManager.FindByIdAsync(id);

            if (user == default)
            {
                return(NotFound("Unable to find user"));
            }

            var role = await _roleManager.FindByIdAsync(request.RoleId);

            if (role == default)
            {
                return(NotFound("Unable to find role"));
            }

            var result = await _userManager.AddToRoleAsync(user, role.Name);

            return(Ok(result.Succeeded));
        }
예제 #2
0
 public Task <bool> ApplyRoleAsync(Guid id, ApplyRoleRq request) =>
 PutAsync($"/api/user/{id}/applyrole", request);