Exemplo n.º 1
0
        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();
        }