Exemple #1
0
        async void OnSaveButtonClicked(object sender, EventArgs e)
        {
            bool valid = true;

            if (this.Entry_UserName.Text.Trim().Length == 0)
            {
                valid = false;
                await DisplayAlert("Error", "กรุณาระบุ User Name", "OK");
            }
            if (valid && this.Entry_Password.Text.Trim().Length == 0)
            {
                valid = false;
                await DisplayAlert("Error", "กรุณาระบุ Password", "OK");
            }

            if (valid && this.Entry_RePassword.Text.Trim().Length == 0)
            {
                valid = false;
                await DisplayAlert("Error", "กรุณาระบุ Re Password", "OK");
            }

            if (valid && !this.Entry_RePassword.Text.Trim().Equals(this.Entry_Password.Text.Trim()))
            {
                valid = false;
                await DisplayAlert("Error", "กรุณาระบุ Password เท่ากับ Re Password", "OK");
            }


            if (valid && this.picker.SelectedIndex == -1)
            {
                valid = false;
                await DisplayAlert("Error", "กรุณาระบุ User Level ", "OK");
            }

            string userLevel     = "";
            int    selectedIndex = picker.SelectedIndex;

            if (selectedIndex != -1)
            {
                userLevel = (string)picker.ItemsSource[selectedIndex];
            }



            if (valid)
            {
                if (bt_Confirm.Text.Equals("Confirm Update"))
                {
                    //Update
                    await firebaseHelper.UpdateUser(this.user_id, this.Entry_UserName.Text.Trim(), this.Entry_Password.Text.Trim(), this.Entry_Detail.Text.Trim(), userLevel);
                    await DisplayAlert("Complete", "Update Complete", "OK");

                    bt_Confirm.Text = "Confirm";

                    await Navigation.PushAsync(new ListUserAdmin());
                }
                else
                {
                    //Insert
                    await firebaseHelper.AddUser(this.Entry_UserName.Text.Trim(), this.Entry_Password.Text.Trim(), this.Entry_Detail.Text.Trim(), userLevel);

                    await DisplayAlert("Complete", "Insert Complete", "OK");

                    bt_Confirm.Text = "Confirm";

                    await Navigation.PushAsync(new ListUserAdmin());
                }        //end if
            }            //end if
        }
Exemple #2
0
 //Update
 public async Task <bool> UpdateUser(Guid Id, string email, string password)
 {
     return(await UserFirebaseHelper.UpdateUser(Id, email, password));
 }