async void Save_Clicked(object sender, EventArgs e) { if (!viewModel.IsImageSet) { await DisplayAlert("Add an image!", "Before saving the person you must add an image.", "OK"); return; } if (viewModel.Person.name.Length == 0) { await DisplayAlert("Invalid Name!", "Name can not be empty.", "OK"); return; } try { // Processing dialog. using (UserDialogs.Instance.Loading("Processing", null, null, true, MaskType.Black)) { var imageStream = await viewModel.GetImageStreamAsync(); await PeopleViewModel.AddPersonAsync(viewModel.Person, imageStream); } } catch (Exception ex) { await DisplayAlert("Error!", ex.Message, "OK"); return; } await Navigation.PopAsync(); }