/// <summary>
        /// 更新人员信息,此处只更新人员的名称,在工号相同的情况下
        /// </summary>
        /// <param name="_userManager"></param>
        /// <returns></returns>
        public async Task <ApplicationUser> UpdateUserInfo(UserManager <ApplicationUser> _userManager)
        {
            var userInfo = await _userManager.Users.FirstOrDefaultAsync(a => a.Id == Id);

            if (userInfo != null)
            {
                //如果人员的名称相同,则不处理
                if (userInfo.FamilyName == FamilyName && userInfo.FirstName == FirstName)
                {
                    return(userInfo);
                }
                userInfo.FamilyName = FamilyName;
                userInfo.FirstName  = FirstName;
                userInfo.Telephone  = Telephone;
                var result = await _userManager.UpdateAsync(userInfo);

                if (result.Succeeded)
                {
                    //更改UserClaim
                    var userClaims = new Dictionary <string, string>();
                    userClaims.Add("family_name", FamilyName);
                    userClaims.Add("given_name", FirstName);
                    userClaims.Add("preferred_username", FamilyName + FirstName);
                    EditUserClaimViewModel updateUserClaim = new EditUserClaimViewModel
                    {
                        Id         = Id,
                        UserClaims = userClaims
                    };
                    var user = await updateUserClaim.UpdateUserClaims(_userManager);

                    return(user);
                }
            }
            return(null);
        }
        private async Task <ApplicationUser> UpdateUserInfo(Guid id, string familyName, string firstName, string telephone)
        {
            var userInfo = await _userManager.Users.FirstOrDefaultAsync(a => a.Id == id);

            if (userInfo != null)
            {
                userInfo.FamilyName = familyName;
                userInfo.FirstName  = firstName;
                userInfo.Telephone  = telephone;
                var result = await _userManager.UpdateAsync(userInfo);

                if (result.Succeeded)
                {
                    //更改UserClaim
                    var userClaims = new Dictionary <string, string>();
                    userClaims.Add("family_name", familyName);
                    userClaims.Add("given_name", firstName);
                    userClaims.Add("preferred_username", familyName + firstName);
                    EditUserClaimViewModel updateUserClaim = new EditUserClaimViewModel
                    {
                        Id         = id,
                        UserClaims = userClaims
                    };
                    var user = await updateUserClaim.UpdateUserClaims(_userManager);

                    return(user);
                }
                else
                {
                    AddErrors(result);
                }
            }
            return(null);
        }
        public async Task <IActionResult> EditUserClaim(EditUserClaimViewModel editUserClaimViewModel)
        {
            if (ModelState.IsValid)
            {
                //ApplicationUser user = await EditUserClaimToUser(editUserClaimViewModel.Id, editUserClaimViewModel.UserClaims);
                ApplicationUser user = await editUserClaimViewModel.UpdateUserClaims(_userManager);

                if (user != null)
                {
                    return(RedirectToAction(nameof(Index), new { id = user.Id }));
                }
            }
            return(View(editUserClaimViewModel));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Application User Id</param>
        /// <returns></returns>
        public async Task <IActionResult> EditUserClaim(Guid?id)
        {
            if (!id.HasValue || id.Value.Equals(Guid.Empty))
            {
                return(BadRequest());
            }
            var userModel = await _userManager.Users.Include(a => a.Claims).Where(a => a.Id == id).FirstOrDefaultAsync();

            if (userModel != null)
            {
                var viewModel = new EditUserClaimViewModel
                {
                    Id         = userModel.Id,
                    FullName   = userModel.FullName,
                    UserName   = userModel.UserName,
                    UserClaims = userModel.Claims.OrderBy(a => a.ClaimType).Select(a => new { ClaimType = a.ClaimType, ClaimValue = a.ClaimValue }).ToDictionary(a => a.ClaimType, a => a.ClaimValue)
                };
                return(View(viewModel));
            }
            return(BadRequest());
        }