public JsonResult UpdateProfile(ProfileModel model) { try { Assert.ArgumentNotNull(model, "UpdateProfileInputModel"); var result = new ProfileBaseJsonResult(); this.ValidateModel(result); if (result.HasErrors) { return(Json(result, JsonRequestBehavior.AllowGet)); } if (!Context.User.IsAuthenticated || Context.User.Profile.IsAdministrator) { return(Json(result)); } result = _accountRepository.UpdateProfile(model); return(Json(result)); } catch (Exception e) { _logger.LogError("UpdateProfile", this, e); return(Json(new BaseJsonResult("UpdateProfile", e), JsonRequestBehavior.AllowGet)); } }
public JsonResult UpdateProfile(ProfileModel model) { try { Assert.ArgumentNotNull(model, "UpdateProfileInputModel"); ProfileBaseJsonResult result = new ProfileBaseJsonResult(); this.ValidateModel(result); if (result.HasErrors) { return(Json(result, JsonRequestBehavior.AllowGet)); } if (!Context.User.IsAuthenticated || Context.User.Profile.IsAdministrator) { return(Json(result)); } var response = this.AccountManager.UpdateUser(this.CurrentStorefront, this.CurrentVisitorContext, model); result.SetErrors(response.ServiceProviderResult); if (response.ServiceProviderResult.Success && !string.IsNullOrWhiteSpace(model.Password) && !string.IsNullOrWhiteSpace(model.PasswordRepeat)) { var changePasswordModel = new ChangePasswordInputModel { NewPassword = model.Password, ConfirmPassword = model.PasswordRepeat }; var passwordChangeResponse = this.AccountManager.UpdateUserPassword(this.CurrentStorefront, this.CurrentVisitorContext, changePasswordModel); result.SetErrors(passwordChangeResponse.ServiceProviderResult); if (passwordChangeResponse.ServiceProviderResult.Success) { result.Initialize(response.ServiceProviderResult); } } return(Json(result)); } catch (Exception e) { CommerceLog.Current.Error("UpdateProfile", this, e); return(Json(new BaseJsonResult("UpdateProfile", e), JsonRequestBehavior.AllowGet)); } }
public ProfileBaseJsonResult UpdateProfile(ProfileModel model) { var result = new ProfileBaseJsonResult(); var response = this.AccountManager.UpdateUser(this.CurrentStorefront, this.CurrentVisitorContext, model); result.SetErrors(response.ServiceProviderResult); if (response.ServiceProviderResult.Success && !string.IsNullOrWhiteSpace(model.Password) && !string.IsNullOrWhiteSpace(model.PasswordRepeat)) { var changePasswordModel = new ChangePasswordInputModel { NewPassword = model.Password, ConfirmPassword = model.PasswordRepeat }; var passwordChangeResponse = this.AccountManager.UpdateUserPassword(this.CurrentStorefront, this.CurrentVisitorContext, changePasswordModel); result.SetErrors(passwordChangeResponse.ServiceProviderResult); if (passwordChangeResponse.ServiceProviderResult.Success) { result.Initialize(response.ServiceProviderResult); } } return(result); }
public JsonResult UpdateProfile(ProfileModel model) { try { Assert.ArgumentNotNull(model, "UpdateProfileInputModel"); ProfileBaseJsonResult result = new ProfileBaseJsonResult(); this.ValidateModel(result); if (result.HasErrors) { return Json(result, JsonRequestBehavior.AllowGet); } if (!Context.User.IsAuthenticated || Context.User.Profile.IsAdministrator) { return Json(result); } var response = this.AccountManager.UpdateUser(this.CurrentStorefront, this.CurrentVisitorContext, model); result.SetErrors(response.ServiceProviderResult); if (response.ServiceProviderResult.Success && !string.IsNullOrWhiteSpace(model.Password) && !string.IsNullOrWhiteSpace(model.PasswordRepeat)) { var changePasswordModel = new ChangePasswordInputModel { NewPassword = model.Password, ConfirmPassword = model.PasswordRepeat }; var passwordChangeResponse = this.AccountManager.UpdateUserPassword(this.CurrentStorefront, this.CurrentVisitorContext, changePasswordModel); result.SetErrors(passwordChangeResponse.ServiceProviderResult); if (passwordChangeResponse.ServiceProviderResult.Success) { result.Initialize(response.ServiceProviderResult); } } return Json(result); } catch (Exception e) { CommerceLog.Current.Error("UpdateProfile", this, e); return Json(new BaseJsonResult("UpdateProfile", e), JsonRequestBehavior.AllowGet); } }