public async Task UpdateTaskAsync(Volunteer item) { await volunteerTable.UpdateAsync(item); }
async void Submit(object sender, System.EventArgs e) { try { indicator.IsVisible = true; if (email.Text.Trim().isEmail()) { label1.IsVisible = false; if (phone.Text.IsPhone()) { label2.IsVisible = false; if (picker.SelectedItem.ToString().Equals("Mentor")) { List <Volunteer> v1 = await vol.GetIDAsync(email.Text.Trim()); if (v1.Count > 0) { if (!v1[0].Phone.Equals(phone.Text.Trim())) { await DisplayAlert("Sorry", " This email is in use please enter another one.", "Ok"); } else { List <Volunteer> v2 = await vol.GetbyPhoneAsync(phone.Text.Trim(), email.Text.Trim()); if (v2.Count > 0) { await DisplayAlert("Sorry", " This phone number is in use please enter another one.", "Ok"); } else { Application.Current.Properties["skip"] = "false"; Application.Current.Properties["Status"] = picker.SelectedItem.ToString(); Application.Current.Properties["Email"] = email.Text.Trim(); Application.Current.Properties["Phone"] = phone.Text.Trim(); await transform(); Navigation.RemovePage(this); } } } else { List <Volunteer> v2 = await vol.GetbyPhoneAsync(phone.Text.Trim(), email.Text.Trim()); if (v2.Count > 0) { await DisplayAlert("Sorry", " This phone number is in use please enter another one.", "Ok"); } else { var people = new Volunteer { Status = "Mentor", Email = email.Text.Trim(), Phone = phone.Text.Trim(), Name = "", Postcode = "", Skill = "" }; await vol.SaveTaskAsync(people); Application.Current.Properties["skip"] = "false"; Application.Current.Properties["Status"] = picker.SelectedItem.ToString(); Application.Current.Properties["Email"] = email.Text.Trim(); Application.Current.Properties["Phone"] = phone.Text.Trim(); await transform(); Navigation.RemovePage(this); } } } if (picker.SelectedItem.ToString().Equals("Volunteer")) { List <Volunteer> v1 = await vol.GetIDAsync(email.Text.Trim()); if (v1.Count > 0) { if (!v1[0].Phone.Equals(phone.Text.Trim())) { await DisplayAlert("Sorry", " This email is in use please enter another one.", "Ok"); } else { List <Volunteer> v2 = await vol.GetbyPhoneAsync(phone.Text.Trim(), email.Text.Trim()); if (v2.Count > 0) { await DisplayAlert("Sorry", " This phone number is in use please enter another one.", "Ok"); } else { Application.Current.Properties["skip"] = "false"; Application.Current.Properties["Status"] = picker.SelectedItem.ToString(); Application.Current.Properties["Email"] = email.Text.Trim(); Application.Current.Properties["Phone"] = phone.Text.Trim(); await transform(); Navigation.RemovePage(this); } } } else { List <Volunteer> v2 = await vol.GetbyPhoneAsync(phone.Text.Trim(), email.Text.Trim()); if (v2.Count > 0) { await DisplayAlert("Sorry", " This phone number is in use please enter another one.", "Ok"); } else { var people = new Volunteer { Status = "Volunteer", Email = email.Text.Trim(), Phone = phone.Text.Trim(), Name = "", Postcode = "", Skill = "" }; await vol.SaveTaskAsync(people); Application.Current.Properties["skip"] = "false"; Application.Current.Properties["Status"] = picker.SelectedItem.ToString(); Application.Current.Properties["Email"] = email.Text.Trim(); Application.Current.Properties["Phone"] = phone.Text.Trim(); await transform(); Navigation.RemovePage(this); } } } if (picker.SelectedItem.ToString().Equals("Learner")) { List <Learner> l1 = await per.GetIDAsync(email.Text.Trim()); if (l1.Count > 0) { if (!l1[0].Phone.Equals(phone.Text.Trim())) { await DisplayAlert("Sorry", " This email is in use please enter another one.", "Ok"); } else { List <Learner> l2 = await per.GetbyPhoneAsync(phone.Text.Trim(), email.Text.Trim()); if (l2.Count > 0) { await DisplayAlert("Sorry", " This phone number is in use please enter another one.", "Ok"); } else { Application.Current.Properties["skip"] = "false"; Application.Current.Properties["Status"] = picker.SelectedItem.ToString(); Application.Current.Properties["Email"] = email.Text.Trim(); Application.Current.Properties["Phone"] = phone.Text.Trim(); await transform(); Navigation.RemovePage(this); } } } else { List <Learner> l2 = await per.GetbyPhoneAsync(phone.Text.Trim(), email.Text.Trim()); if (l2.Count > 0) { await DisplayAlert("Sorry", " This phone number is in use please enter another one.", "Ok"); } else { var people = new Learner { Status = "Learner", Email = email.Text.Trim(), Phone = phone.Text.Trim(), Name = "", Postcode = "", Skill = "" }; await per.SaveTaskAsync(people); Application.Current.Properties["skip"] = "false"; Application.Current.Properties["Status"] = picker.SelectedItem.ToString(); Application.Current.Properties["Email"] = email.Text.Trim(); Application.Current.Properties["Phone"] = phone.Text.Trim(); await transform(); Navigation.RemovePage(this); } } } } else { label2.IsVisible = true; } } else { label1.IsVisible = true; } indicator.IsVisible = false; } catch (NullReferenceException ex) { await DisplayAlert("Alert", "You need to choose status and finish the form", "ok"); } }