コード例 #1
0
ファイル: UserController.cs プロジェクト: DStrik/BookCave
        public async Task <IActionResult> ChangeFirstLastName(UserChangeName Name)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var user = await _userManager.GetUserAsync(HttpContext.User);

            var claim = await _userManager.GetClaimsAsync(user);

            var result = await _userManager.ReplaceClaimAsync(user, ((ClaimsIdentity)User.Identity).Claims.FirstOrDefault(c => c.Type == "Name"), new Claim("Name", $"{Name.FirstName} {Name.LastName}"));

            if (result.Succeeded)
            {
                user.FirstName = Name.FirstName;
                user.LastName  = Name.LastName;
                var updateResult = await _userManager.UpdateAsync(user);

                if (updateResult.Succeeded)
                {
                    return(Ok());
                }
            }

            return(BadRequest());
        }
コード例 #2
0
        private async void ExecuteRunNameExtendedDialog(object o)
        {
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view   = new UserChangeName();
            var viewVM = new UserChangeNameVM(view, "");

            view.DataContext = viewVM;
            //show the dialog
            //await DialogHost.Show(view, o, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
            await DialogHostEx.ShowDialog(GlobalUser.MainWin, view, ExtendedOpenedEventHandler, ExtendedClosingEventHandler);

            dialogNum = 1;
        }