private async void UserToLogin_OnClick(object sender, RoutedEventArgs e) { ProgressBar.Visibility = Visibility.Visible; UserHasInputControl(false); var uapi = new UserApi("5940771a096a5bf6e36f530769a6ba2f"); if (string.IsNullOrEmpty(UserUsername.Text) || string.IsNullOrEmpty(UserPwd.Password)) { ProgressBar.Visibility = Visibility.Collapsed; UserPwd.Password = ""; MessageBox.Show( "The credentials entered are either blank or not in a valid format. Try again.", ":(", MessageBoxButton.OK); } else { try { var y = await uapi.ApiLogin(UserPwd.Password, UserUsername.Text); if (y.success.Contains("logged in") || y.success.Contains("Logged In")) { FilingCabinet.CurrentUserCredentials.Consumerkey = y.consumerkey; FilingCabinet.CurrentUserCredentials.Consumersecret = y.consumersecret; FilingCabinet.CurrentUserCredentials.UserTown = "514628d17fa6866d15000038"; //todo !DEBUG! NEEDS TO UPDATE TempAppData.CurrentTown = FilingCabinet.TownsList.Find(i => i.id == (FilingCabinet.CurrentUserCredentials.UserTown)); NavigationService.Navigate(new Uri("/Pages/MainHub.xaml", UriKind.Relative)); } else { MessageBox.Show("Login unsuccessful.\nComputer says: " + y.success, ":(", MessageBoxButton.OK); } } catch (Exception ex) { MessageBox.Show("We could not sign you in at this time, please check details and try again.", ":(", MessageBoxButton.OK); } } UserHasInputControl(true); }