private async void ProcessLogin() { try { Dispatcher.Invoke(() => { UsernameInput.IsEnabled = false; PasswordInput.IsEnabled = false; LoginBtn.IsEnabled = false; RememberMeCheckbox.IsEnabled = false; }); App.UserLogin = UsernameInput.Text; App.UserPassword = PasswordInput.Password; string userData = Functions.Base64Encode(string.Format("{0}:{1}", App.UserLogin, App.UserPassword)); App.client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", userData); string json_data = await App.client.GetStringAsync(Globals.baseURL + "StudentLogin"); if (!string.IsNullOrEmpty(json_data)) { JsonBasicResult <StudentLoginResult> json = JsonConvert.DeserializeObject <JsonBasicResult <StudentLoginResult> >(json_data); if (json.ok) { App.UserType = Helpers.Enums.UserType.Candidate; App.ManagerProfile = json.data.Manager; App.StudentProfile = json.data.Student; App.StudentProfile.ProcessData(); if (RememberMe) { DbContext.AddRememberMe(new DbRememberMe { Email = UsernameInput.Text, Type = (int)DataLayer.Enums.RememberMeType.Candidate }); } else if (DbRememberMe != null) { DbContext.DeleteRememberMe(DbRememberMe); } if (!Functions.AppVerified(out _)) { DbContext.AddVerified(new DbVerified { Email = App.ManagerProfile.Email }); } SetMainWindowContent(new Layout(Logout)); } else { throw new Exception(json.message); } } else { throw new Exception("Username or password incorrect!"); } } catch (Exception ex) { Functions.ShowErrorMessageDialog(ex); Dispatcher.Invoke(() => { UsernameInput.IsEnabled = true; PasswordInput.IsEnabled = true; LoginBtn.IsEnabled = true; RememberMeCheckbox.IsEnabled = true; }); } }