private async void LookupRegistrantByEmail() { txtbxMessages.Text = "Looking up your registration info..."; //Disable form controls during lookup btnSearch.Visibility = System.Windows.Visibility.Collapsed; btnSearch.IsEnabled = false; btnCancel.Visibility = System.Windows.Visibility.Collapsed; btnCancel.IsEnabled = false; try { if ((controller.ActiveRegistrant = await controller.WebAPI.GetRegistrantByEmail(txtbxEmail.Text)) == null) { txtbxMessages.Text = String.Format("{1}{0}{2}{0}{3}{0}{4}", Environment.NewLine, "Your registration info was not found.", "Please check your email and try again.", "If the problem persists, start over and", "click 'Register' to continue checking in."); } else { controller.DisplayRegistrant(); //Reset prompt txtbxMessages.Text = "Enter your email below."; txtbxEmail.Clear(); } } catch (System.Net.Http.HttpRequestException http_ex) { controller.Disconnect(); txtbxMessages.Text = String.Format("{1}{0}{2}", Environment.NewLine, "Online connection lost. Returning to offline mode.", "Please check your internet connection and try again."); controller.LogError("Online connection lost.", http_ex.Message); btnSearch.Visibility = System.Windows.Visibility.Visible; btnCancel.Visibility = System.Windows.Visibility.Visible; btnCancel.IsEnabled = true; return; } catch (Exception ex) { txtbxMessages.Text = String.Format("{1}{0}{2}{0}{3}", Environment.NewLine, "An error occurred. Please try again.", "If the problem persists, start over and", "click 'Register' to continue checking in."); controller.LogError(ex.Message); } //Reenable form controls after lookup btnSearch.Visibility = System.Windows.Visibility.Visible; btnSearch.IsEnabled = true; btnCancel.Visibility = System.Windows.Visibility.Visible; btnCancel.IsEnabled = true; }
private void btnDisconnect_Click(object sender, RoutedEventArgs e) { BtnClick(sender, e); controller.Disconnect(); }