コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: vnsnippets/workshops
        private async void ButtonAdd_Clicked(object sender, EventArgs e)
        {
            ToggleIndicator();
            if (!FormValidationSuccess())
            {
                await DisplayAlert("Error", "Name and person are required fields", "OK");

                return;
            }

            var person = await _service.GetPerson(TxtName.Text);

            if (person != null)
            {
                await DisplayAlert("Error", "A person with that name already exist", "OK");

                return;
            }

            await _service.AddPerson(TxtName.Text, TxtPhone.Text);

            TxtName.Text  = string.Empty;
            TxtPhone.Text = string.Empty;

            await DisplayAlert("Success", "Person Added Successfully", "OK");

            await ReloadPeopleList();

            ToggleIndicator();
        }
コード例 #2
0
        private async void BtnAdd_Clicked(object sender, EventArgs e)
        {
            await firebaseHelper.AddPerson(Convert.ToInt32(txtPersonId.Text), txtName.Text, txtDescription.Text, txtAddress.Text);

            txtPersonId.Text    = string.Empty;
            txtName.Text        = string.Empty;
            txtDescription.Text = string.Empty;
            txtAddress.Text     = string.Empty;
            await DisplayAlert("Success", "Data Added Successfully", "OK");

            var allPersons = await firebaseHelper.GetAllPersons();

            lstPersons.ItemsSource = allPersons;
        }