public async Task <IActionResult> UserRolesManage(string id, GridUsersViewModel vmPrevious)
        {
            var user = await _userManager.FindByIdAsync(id);

            if (user == null)
            {
                return(NotFound());
            }

            var userRoles = await _userManager.GetRolesAsync(user);

            //TODO check the previous error with the old system
            List <UserRolesViewModel> rolesView = new List <UserRolesViewModel>();

            foreach (var role in _roleManager.Roles)
            {
                var userRole = new UserRolesViewModel
                {
                    RoleName = role.Name,
                    IsActive = userRoles.Contains(role.Name)
                };
                rolesView.Add(userRole);
            }
            UserRolesManageViewModel vm = new UserRolesManageViewModel
            {
                UserId     = id,
                Roles      = rolesView,
                VmPrevious = vmPrevious
            };

            return(View(vm));
        }
        public IActionResult GetUsersGrid(GridUsersViewModel vm)
        {
            var pageData = _userManager.GetUserPageAsync(vm.Text, vm.Page, vm.PageSize, vm.Sort, vm.Ascending);

            vm.TotalUsers = pageData.TotalUsers;
            vm.Users      = pageData.Users;
            return(View(vm));
        }
        public async Task <IActionResult> UserRolesManage(string id, GridUsersViewModel vmPrevious)
        {
            var user = await _userManager.FindByIdAsync(id);

            if (user == null)
            {
                return(NotFound());
            }

            var userRoles = await _userManager.GetRolesAsync(user);

            var vm = new UserRolesManageViewModel
            {
                UserId = id,
                Roles  = _roleManager.Roles.Select(x => new UserRolesViewModel
                {
                    RoleName = x.Name,
                    IsActive = userRoles.Contains(x.Name)
                }),
                VmPrevious = vmPrevious
            };

            return(View(vm));
        }