private async Task ExecuteOnAddContact() { var props = typeof(NewContact_Model).GetProperties(); string[] required = { "lastname", "firsname", "business_type", "sector", "placement", "sex", "local_appearance", "prescription", "wilaya", "city", "address" }; bool valid = true; foreach (var prop in props) { if (required.Contains(prop.Name)) { object value = prop.GetValue(Contact, null); if (string.IsNullOrWhiteSpace((string)value)) { IsBusy = false; DependencyService.Get <IMessage>().ShortAlert("Vous devez remplir les champs obligatoires !"); valid = false; return; } } } if (CheckIfContactExiste()) { IsBusy = false; DependencyService.Get <IMessage>().ShortAlert("Contact Exsite Déja !"); return; } if (string.IsNullOrWhiteSpace(Contact.location.coordinates.lat) & valid) { valid = false; DependencyService.Get <IMessage>().ShortAlert("Impossible d'ajouter un Contact sans sa position gps !"); } if (valid) { if (await DependencyService.Get <IDialog>().AlertAsync("", "Voulez Vous Ajouter le Contact " + Contact.lastname + " " + Contact.firstname + " ?", "Oui", "Non")) { var json = JsonConvert.SerializeObject(Contact); System.Diagnostics.Debug.WriteLine(json); var contact_data = new NewContactToUpload_Model { Date = DateTime.Now, Json = json, Name = Contact.lastname + " " + Contact.firstname, PicturePath = PicturePath }; DataStore.AddContactToUpload(contact_data); MessagingCenter.Send(this, "UploadContactsTableModified"); await Navigation.PopModalAsync(); } } }