public async Task <IActionResult> EditProfile(UserEditBindingModel model) { var user = await this.userManager.GetUserAsync(this.User); if (!ModelState.IsValid) { return(View(model)); } if (user == null) { return(this.NotFound()); } var email = user.Email; if (model.Email != email) { var setEmailResult = await userManager.SetEmailAsync(user, model.Email); if (!setEmailResult.Succeeded) { return(NotFound()); } } var phoneNumber = user.PhoneNumber; if (model.PhoneNumber != phoneNumber) { var setPhoneResult = await userManager.SetPhoneNumberAsync(user, model.PhoneNumber); if (!setPhoneResult.Succeeded) { return(NotFound()); } } if (model.NewPicture != null) { try { await photoService.AddPhotoToUser(model.NewPicture, user.UserName); } catch { this.Error(NotificationMessages.ImageUploadError); return(View(model)); } } user.AboutMe = model.AboutMe; user.Address = model.Address; await this.userManager.UpdateAsync(user); this.Success(NotificationMessages.AccountUpdated); return(RedirectToAction(nameof(EditProfile))); }