Exemplo n.º 1
0
        public async Task <IActionResult> GetUserRoleById([FromRoute] string userId)
        {
            IList <string> userRoles;

            if (UserId == userId || IsAdministrator)
            {
                User user = await _accountBl.FindByIdAsync(userId);

                if (user == null)
                {
                    return(BadRequest("There is no User with that ID "));
                }
                else
                {
                    userRoles = await _accountBl.GetRolesAsync(user);
                }
                return(new OkObjectResult(userRoles));
            }
            else
            {
                return(BadRequest("Can not get roles for this user"));
            }
        }