private async void start_Clicked(object sender, EventArgs e) { try { SearchCServerCapsula capsula = null; using (LoadingLock theLock = new LoadingLock(this, "Trying to find the user...")) { await Task.Run(() => { if (userNameEntry.Text == null || !Validators.ValidateRegexUserName(userNameEntry.Text)) { if (int.TryParse(publicIdEntry.Text, out int publicId)) { capsula = app.connection.SearchContact(publicId); } else { return; } } else { capsula = app.connection.SearchContact(userNameEntry.Text); } }); } if (capsula == null) { ShowError("Parsing input", "Public id nor username isn't correct."); return; } if (!capsula.Succeeded) { ShowError("Searching user", "User not found"); } else { await Navigation.PopModalAsync(); await app.MainPage.Navigation.PushModalAsync(new NavigationPage(new ContactDetail(app.settings, capsula, app))); } } catch (Exception ex) { app.logger.LogException(this, ex); ShowError(ex.Source, ex.Message); } }
private async Task SaveTrustification(bool trust) { using (LoadingLock theLock = new LoadingLock(this, "Saving trust changes to server...")) { switch (trustedSwitch.IsToggled) { case true: await Task.Run(() => app.connection.TrustContact((int)contact.PublicId)); break; case false: await Task.Run(() => app.connection.UntrustContact((int)contact.PublicId)); break; } } }