private async Task <bool> ValidateForm(Models.Models.Client client) { if (client.Firstname == null || client.Lastname == null) { var dialog = new MessageDialog("Veuillez indiquer les champs obligatoires !"); await dialog.ShowAsync(); return(true); } return(false); }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { var deferral = args.GetDeferral(); Models.Models.Client client = new Models.Models.Client { Firstname = (Firstname.Text != "") ? Firstname.Text : null, Lastname = (Lastname.Text != "") ? Lastname.Text : null, Phone = (Phone.Text != "") ? Phone.Text : null, Email = (Email.Text != "") ? Email.Text : null, }; args.Cancel = await ValidateForm(client); if (!args.Cancel) { bool Response = await RestClient.Instance.Post <Models.Models.Client>(client); } deferral.Complete(); }