private void DeleteButton_Click(object sender, EventArgs e) { Toast.MakeText(this, "delete success!", ToastLength.Short).Show(); ContactList.Remove(ContactList.FirstOrDefault(c => c.Id == _contactSelected.Id)); ListAdapter.NotifyDataSetChanged(); _dialog.Dismiss(); // Finish(); }
private void DoneButton_Click(object sender, EventArgs e) { EditText name = (EditText)_dialog.FindViewById(Resource.Id.firstNameTxt); EditText lastName = (EditText)_dialog.FindViewById(Resource.Id.lastNameTxt); EditText phone = (EditText)_dialog.FindViewById(Resource.Id.phoneNumberTxt); EditText email = (EditText)_dialog.FindViewById(Resource.Id.emailTxt); int isValid = ValidateData(name.Text, lastName.Text, phone.Text, email.Text); if (isValid != 0) { switch (isValid) { case 1: Toast.MakeText(this, "Information Missing!", ToastLength.Short).Show(); break; case 2: Toast.MakeText(this, "Invalid Email!", ToastLength.Short).Show(); break; case 3: Toast.MakeText(this, "Invalid Phone!", ToastLength.Short).Show(); break; default: break; } return; } if (_IsContactNew) { //Add new Contact ContactList.Add(new Contact() { Name = name.Text, LastName = lastName.Text, Phone = phone.Text, Email = email.Text }); ListAdapter.NotifyDataSetChanged(); } else { //Edit Contact var contactToBeUpdated = ContactList.FirstOrDefault(c => c.Id == _contactSelected.Id); if (contactToBeUpdated == null) { Toast.MakeText(this, "Invalid Contact!", ToastLength.Short).Show(); return; } contactToBeUpdated.Name = name.Text; contactToBeUpdated.LastName = lastName.Text; contactToBeUpdated.Phone = phone.Text; contactToBeUpdated.Email = email.Text; } _dialog.Dismiss(); }