public async Task <IActionResult> Edit(UserAdminProfileViewModel userAdminProfileViewModel) { string userName = userAdminProfileViewModel.UserName; string phoneNumber = userAdminProfileViewModel.PhoneNumber; if (!ModelState.IsValid) { return(UpadateError(userAdminProfileViewModel, EditNgMessage)); } var user = await _userManager.GetUserAsync(User).ConfigureAwait(false); if (user == null) { return(UpadateError(userAdminProfileViewModel, EditNgMessage)); } var identityResult = await _userManager.SetUserNameAsync(user, userName).ConfigureAwait(false); if (!identityResult.Succeeded) { return(UpadateError(userAdminProfileViewModel, EditNgMessage)); } identityResult = await _userManager.SetPhoneNumberAsync(user, phoneNumber).ConfigureAwait(false); if (!identityResult.Succeeded) { return(UpadateError(userAdminProfileViewModel, EditNgMessage)); } userAdminProfileViewModel.Notification = EditOkMessage; userAdminProfileViewModel.UpdateResult = true; return(View("Index", userAdminProfileViewModel)); }
private IActionResult UpadateError(UserAdminProfileViewModel userAdminProfileViewModel, string message) { userAdminProfileViewModel.Notification = message; userAdminProfileViewModel.UpdateResult = false; return(View("Index", userAdminProfileViewModel)); }
public async Task <IActionResult> Index() { var user = await _userManager.GetUserAsync(User).ConfigureAwait(false); UserAdminProfileViewModel userAdminProfileViewModel = new UserAdminProfileViewModel { UserId = user.Id, UserName = user.UserName, PhoneNumber = user.PhoneNumber, }; return(View("Index", userAdminProfileViewModel)); }