public async Task <IActionResult> Index(UserProfileViewModel model) { var userState = _userStateWrapper.GetUserState(); if (userState == null || userState.Id == 0) { return(RedirectToAction("Logon", "Member")); } if (ModelState.IsValid) { if (model.Id != userState.Id) { ModelState.AddModelError(Constants.ModelStateCustomErrorKey, NotMachingUserId); } else { var user = await _memberService.GetUserByIdAsync(userState.Id); user = model.ChangeUser(user); // TODO: Check result var result = await _memberService.UpdateUserAsync(user); await _signinManager.SignOffAsync(); await _signinManager.SignInAsync(UserState.FromUser(user)); model.FromUser(user); } } return(View(model)); }