コード例 #1
0
ファイル: SignUpViewModel.cs プロジェクト: AJDekker/ToDoApp
        private async void SignUp()
        {
            //null or empty field validation, check weather email and password is null or empty

            if (string.IsNullOrEmpty(Email) || string.IsNullOrEmpty(Password))
            {
                await App.Current.MainPage.DisplayAlert("Empty Values", "Please enter Email and Password", "OK");
            }
            else
            {
                //call AddUser function which we define in Firebase helper class
                var user = await UserFirebaseHelper.AddUser(Email, Password);

                //AddUser return true if data insert successfuly
                if (user)
                {
                    await App.Current.MainPage.DisplayAlert("SignUp Success", "", "Ok");

                    //Navigate to Wellcom page after successfuly SignUp
                    //pass user email to welcom page
                    await App.Current.MainPage.Navigation.PushModalAsync(new WelcomePage());
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Error", "SignUp Fail", "OK");
                }
            }
        }
コード例 #2
0
        //Update user data
        private async void Update()
        {
            try
            {
                if (!string.IsNullOrEmpty(Password))
                {
                    var isupdate = await UserFirebaseHelper.UpdateUser(id, Email, Password);

                    if (isupdate)
                    {
                        await App.Current.MainPage.DisplayAlert("Update Success", "", "Ok");
                    }
                    else
                    {
                        await App.Current.MainPage.DisplayAlert("Error", "Record not update", "Ok");
                    }
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Password Require", "Please Enter your password", "Ok");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error:{e}");
            }
        }
コード例 #3
0
        //Delete user data
        private async void Delete()
        {
            try
            {
                var isdelete = await UserFirebaseHelper.DeleteUser(id);

                if (isdelete)
                {
                    await App.Current.MainPage.Navigation.PopAsync();
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Error", "Record not delete", "Ok");
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"Error:{e}");
            }
        }