예제 #1
0
        private async void delete_account(object sender, EventArgs e)
        {
            var result = await DisplayAlert("Are you sure you want to delete your account?",
                                            "If you delete your account all your information will be permanently deleted.", "Yes", "No");

            if (!busyindicator.IsVisible && allowPopup)
            {
                allowPopup = false;
                if (!App.loggedInNow && result)
                {
                    await DisplayAlert("For security reasons", "Please log in again before deleting your account!", "OK");

                    App.UserUID = "";
                    App.Current.Properties.Remove("App.UserUID");
                    await App.Current.SavePropertiesAsync();

                    App.Current.MainPage = new NavigationPage(new LogIn());
                    OnBackButtonPressed();
                }
                if (result && App.loggedInNow) // if it's equal to Yes
                {
                    bool validate = true;
                    try
                    {
                        await authDeleteAccount.DeleteAccount();
                    }
                    catch (Exception)
                    {
                        validate = false;
                    }
                    if (validate)
                    {
                        try
                        {
                            await fireBaseHelperStudent.DeleteStudent(App.UserUID);
                        }
                        catch (Exception)
                        {
                            validate = false;
                        }
                    }
                    if (validate)
                    {
                        App.UserUID          = "";
                        App.Current.MainPage = new NavigationPage(new LogIn());
                        await DisplayAlert("Account deleted", "To use the application again please sign up", "OK");

                        App.Current.Properties.Remove("App.UserUID");
                        await App.Current.SavePropertiesAsync();

                        OnBackButtonPressed();
                    }
                    else
                    {
                        await DisplayAlert("Something went wrong...", "Please check your interner connection", "OK");
                    }
                }
                allowPopup = true;
            }
        }
예제 #2
0
        private async void delete_account(object sender, EventArgs e)
        {
            var result = await DisplayAlert("Are you sure you want to delete your account?",
                                            "If you delete your account all your information will be permanently deleted.", "Yes", "No");

            if (!App.loggedInNow && result)
            {
                await DisplayAlert("For security reasons", "Please log in again before deleting your account!", "Ok");

                App.UserUID = "";
                App.Current.Properties.Remove("App.UserUID");
                await App.Current.SavePropertiesAsync();

                App.Current.MainPage = new NavigationPage(new LogIn());
                OnBackButtonPressed();
            }
            if (result && App.loggedInNow) // if it's equal to Yes
            {
                try
                {
                    await fireBaseHelperStudent.DeleteStudent(App.UserUID);

                    await authDeleteAccount.DeleteAccount();

                    App.UserUID          = "";
                    App.Current.MainPage = new NavigationPage(new LogIn());
                    await DisplayAlert("Account deleted", "To use the application again please sign up", "ok");

                    App.Current.Properties.Remove("App.UserUID");
                    await App.Current.SavePropertiesAsync();

                    OnBackButtonPressed();
                }
                catch (Exception)
                {
                    await DisplayAlert("Failed", "Please try again later", "ok");
                }
            }
        }