コード例 #1
0
        public async Task <IActionResult> ChangeUserRoles(int userId, int[] roleIds)
        {
            User thisUser = null;
            var  result   = await _userManager.AddOrUpdateUserRolesAsync(
                userId, roleIds, user => thisUser = user);

            if (!result.Succeeded)
            {
                return(BadRequest(error: result.DumpErrors(useHtmlNewLine: true)));
            }
            return(await returnUserCardPartialView(thisUser));
        }
コード例 #2
0
        public async Task <IActionResult> ChangeUserRoles(int userId, List <int> roleIds)
        {
            User thisUser = null;
            var  result   = await _userManager.AddOrUpdateUserRolesAsync(
                userId, roleIds, user => thisUser = user);

            if (!result.Succeeded)
            {
                return(BadRequest(error: result.DumpErrors(useHtmlNewLine: true)));
            }

            return(RedirectToAction(nameof(Index)));
        }