File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -46,24 +46,24 @@ public async Task<IActionResult> Manage(Guid userId)
46
46
{
47
47
ViewBag . userId = userId ;
48
48
User user = await _userManager . FindByIdAsync ( userId . ToString ( ) ) ;
49
+ IList < string > userRoleList = await _userManager . GetRolesAsync ( user ) ;
49
50
if ( user == null )
50
51
{
51
52
ViewBag . ErrorMessage = $ "User with Id = { userId } cannot be found";
52
53
return View ( "NotFound" ) ;
53
54
}
54
55
ViewBag . UserName = user . UserName ;
55
56
List < ManageUserRolesViewModel > model = new List < ManageUserRolesViewModel > ( ) ;
57
+
56
58
foreach ( Role role in _roleManager . Roles )
57
59
{
58
60
ManageUserRolesViewModel userRolesViewModel = new ManageUserRolesViewModel
59
61
{
60
62
RoleId = role . Id ,
61
63
RoleName = role . Name
62
64
} ;
63
- var b = user . Roles . Where ( x => x . RoleId == role . Id ) . FirstOrDefault ( ) ;
64
- var a = await _userManager . IsInRoleAsync ( user , role . Name ) ;
65
-
66
- if ( await _userManager . IsInRoleAsync ( user , role . Name ) )
65
+ //if (await _userManager.IsInRoleAsync(user, role.Name))
66
+ if ( userRoleList . Contains ( role . Name ) )
67
67
{
68
68
userRolesViewModel . Selected = true ;
69
69
}
You can’t perform that action at this time.
0 commit comments