public static async Task Edit(UserEditModel user, string sessionKey) { var headers = new Dictionary<string, string>(); headers.Add("X-sessionKey", sessionKey); await HttpRequester.Post(baseUrl + "edit", user, headers); }
private async void HandleSaveProfile(object obj) { var stackPanel = obj as StackPanel; var oldPassword = (stackPanel.Children[1] as PasswordBox).Password; var newPassword = (stackPanel.Children[3] as PasswordBox).Password; var user = new UserEditModel() { FirstName = FirstName, LastName = LastName, ProfilePictureUrl = ProfilePictureUrl, OldPasswordHash = (!string.IsNullOrEmpty(oldPassword)) ? Sha1Encrypter.ConvertToSha1(oldPassword) : null, NewPasswordHash = (!string.IsNullOrEmpty(newPassword)) ? Sha1Encrypter.ConvertToSha1(newPassword) : null, }; await UsersPersister.Edit(user, AccountManager.CurrentUser.SessionKey); var newUser = await UsersPersister.GetUserBySessionKey(AccountManager.CurrentUser.SessionKey); AccountManager.CurrentUser = newUser; NotificationsManager.ShowToastNotification("Profile saved successfully"); }