public async Task <IActionResult> Index() { var users = _userDal.GetUsers(); var roles = _roleDal.GetRoles(); UserListViewModel model = new UserListViewModel(); foreach (var user in users) { user.CurrentRoles = (List <string>)(await _userManager.GetRolesAsync(new VesizleUser() { Id = user.Id, UserName = user.UserName })); user.SelectRoles = _mapper.Map <List <SelectListItem> >(roles.Where(role => !user.CurrentRoles.Contains(role.Name))); } model.Users = users; return(View(model)); }