private async void btnLogin_Click(object sender, RoutedEventArgs e) { btnLogin.IsEnabled = false; try { var result = await UsersAPI.Login(txtLogin.Text, txtPass.Password); if(result.error) { lblStatus.Content = result.message; } else { AppPersistent.UserToken = result.data.token; AppPersistent.LocalUserId = result.data.id; PageNavigationManager.SwitchToPage(new ApplicationPage()); } } catch(Exception ex) { MessageBox.Show(ex.Message, "An exception happened"); } }
private async void BtnLogin_Click(object sender, EventArgs e) { ImageView overlay = FindViewById <ImageView>(Resource.Id.loadingOverlay); overlay.Visibility = ViewStates.Visible; m_LoadingGif.Visibility = ViewStates.Visible; var res = await UsersAPI.Login(m_UsernameView.Text, m_PassView.Text); if (res.error) { overlay.Visibility = ViewStates.Invisible; m_LoadingGif.Visibility = ViewStates.Invisible; m_LoginError.Text = res.message; } else { AppPersistent.UserToken = res.data.token; AppPersistent.LocalUserId = res.data.id; var intent = new Intent(this, typeof(MainActivity)); StartActivity(intent); } }