private async Task btnSaveChanges_Clicked(object sender, EventArgs e) { var result = await UserDialogs.Instance.PromptAsync(new PromptConfig { Title = "Confirm", Message = "To confirm changes, please enter your old password!", OkText = "Ok", CancelText = "Cancel", InputType = InputType.Password, }); var EnteredPassword = result.Value; if (result.Ok) { try { User user_try = new User(); user_try.UserId = GlobalVariables.user.UserId; user_try.Password = EnteredPassword; var response = await ImaniManager.CHeckPswAsync(user_try); if (response == "NOK") { await DisplayAlert("Attention!", "The password does not match!", "Ok"); } else if (response == "OK") { user_try.Email = txtEmail.Text; user_try.Name = txtName.Text; if (txtNewPass.Text != null) { user_try.Password = txtNewPass.Text; } else { user_try.Password = EnteredPassword; } await ImaniManager.UpdateUserAsync(user_try); GlobalVariables.user.Name = txtName.Text; await DisplayAlert("Succes!", "Succefully saved!", "Ok"); } } catch { await DisplayAlert("Alert!", "Something went wrong!", "Ok"); } Application.Current.MainPage = new SettingsPage(); } }
//BIJ KLIKKEN OP DELETE ACCOUNT private async void btnDeleteAccount_Clicked(object sender, EventArgs e) { //Na het succesvol verwijderen terug naar de login pagina gaan (LAAT DIT STAAN, DIT IS AL IN ORDE): var resultaat = await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig { OkText = "Ok", CancelText = "Cancel", Message = "Are you sure you would like to delete your account? You will lose all your data!", Title = "Alert!", }); if (resultaat) { var result = await UserDialogs.Instance.PromptAsync(new PromptConfig { Title = "Confirm", Message = "To DELETE your account, please enter your password!", OkText = "Ok", CancelText = "Cancel", InputType = InputType.Password, }); var EnteredPassword = result.Value; try { User user_try = new User(); user_try.UserId = GlobalVariables.user.UserId; user_try.Password = EnteredPassword; var response = await ImaniManager.CHeckPswAsync(user_try); if (response == "NOK") { await DisplayAlert("Attention!", "The password does not match!", "Ok"); } else if (response == "OK") { await ImaniManager.DeleteUserAsync(GlobalVariables.user.UserId.ToString()); await DisplayAlert("Succes!", "Succefully deleted your account! We are now navigating to the login page", "Ok"); GlobalVariables.displayedScreen = "Dashboard"; Application.Current.MainPage = new LoginPage(); } } catch { await DisplayAlert("Alert!", "Something went wrong!", "Ok"); } } }