private async void Page_Loaded(object sender, RoutedEventArgs e) { if (await GlobalHandle.checkLastuser() != null) { userEmail.Text = await GlobalHandle.checkLastuser(); } if (await GlobalHandle.checkPassword() != null) { password.Password = await GlobalHandle.checkPassword(); } }
private async void LoginHandle(object sender, RoutedEventArgs e) { this.currentMember.email = userEmail.Text; this.currentMember.password = password.Password; var data = Services.APIHandle.LoginHandle(this.currentMember).Result; var responseContent = Services.APIHandle.LoginHandle(this.currentMember).Result.Content.ReadAsStringAsync().Result; //Debug.WriteLine(data.Result.Content.ReadAsStringAsync().Result); if (data.StatusCode == System.Net.HttpStatusCode.Created) { // save file... Debug.WriteLine(responseContent); // Luu token GlobalHandle.saveToken(responseContent); //save email last user GlobalHandle.saveLastUser(this.currentMember.email); //save passWord if check savebox if (savePassword.IsChecked == true) { GlobalHandle.savePassWord(this.currentMember.password); } else { if (await GlobalHandle.checkPassword() != null) { GlobalHandle.deletePassword(); } } //Change Account Name in splitView Services.GlobalHandle.changeAccountName(); Services.GlobalHandle.ShowSignOutButton(); // Next page this.Frame.Navigate(typeof(Views.UserInfomation)); } else { ErrorList error = JsonConvert.DeserializeObject <ErrorList>(responseContent); Debug.WriteLine(responseContent); if (error != null && error.error.Count > 0) { var content = ""; foreach (var key in error.error.Keys) { //var textMessage = this.FindName(key); //if (textMessage == null) //{ // continue; //} content += error.error[key].ToString(); //TextBlock textBlock = textMessage as TextBlock; //textBlock.Text = error.error[key]; //textBlock.Visibility = Visibility.Visible; } var messageDialog = new MessageDialog(content); await messageDialog.ShowAsync(); } } }