private void cmdConnect_Click(object sender, RoutedEventArgs e) { Token token = new Token(0, txtLogin.Text, txtPwd.Password, 0); DALClient dal = new DALClient(); DALWSR_Result r = dal.LoginAsync(token, CancellationToken.None); if (r.Data != null) { token = (Token)r.Data; } else { mainVM.MessagePopup = "Problème de connexion."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Problème de connexion"); //essai.ShowAsync(); } if (token.Valid != false) { mainVM.MyForum.TokenUser = token; mainVM.MyForum.User = mainVM.MyForum.User.GetInfoUser(token.IdUser); if (mainVM.MyForum.User != null) { mainVM.MyRegistered = mainVM.MyForum.User; mainVM.IsLogged = true; Frame.Navigate(typeof(MainPage), DataContext); } else { mainVM.MessagePopup = "Problème de connexion."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Problème de connexion"); //essai.ShowAsync(); } } else { mainVM.MyForum.TokenUser = null; mainVM.IsLogged = false; mainVM.MessagePopup = "Login ou mot de passe incorrect."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Login ou mot de passe incorrect"); //essai.ShowAsync(); } }
private void cmdLogin_Click(object sender, RoutedEventArgs e) { if (mainVM.MyForum.TokenUser == null) { Token token = new Token(0, txtLogin.Text, txtPwd.Password, 0); DALClient dal = new DALClient(); DALWSR_Result r = dal.LoginAsync(token, CancellationToken.None); if (r.Data != null) { token = (Token)r.Data; } else { mainVM.MessagePopup = "Problème de connexion."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Problème de connexion"); //essai.ShowAsync(); } if (token.Valid != false) { mainVM.MyForum.TokenUser = token; mainVM.MyForum.User = mainVM.MyForum.User.GetInfoUser(token.IdUser); if (mainVM.MyForum.User != null) { mainVM.MyRegistered = mainVM.MyForum.User; mainVM.IsLogged = true; if (mainVM.MyRegistered.ObjStatus.NameStatus != "Stagiaire") { ShowEditDelete(lstMessage); ShowEditDelete(lstTopic); } } else { mainVM.MessagePopup = "Problème de connexion."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Problème de connexion"); //essai.ShowAsync(); } } else { mainVM.MyForum.TokenUser = null; mainVM.IsLogged = false; mainVM.MessagePopup = "Login ou mot de passe incorrect."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Login ou mot de passe incorrect"); //essai.ShowAsync(); } } else { mainVM.MyForum.TokenUser = null; txtLogin.Text = string.Empty; txtPwd.Password = string.Empty; //mainVM.MyForum.User = null; mainVM.MyRegistered = null; mainVM.IsLogged = false; mainVM.InfoUser = false; ShowEditDelete(lstMessage); ShowEditDelete(lstTopic); } }
private void cmdSaveUser_Click(object sender, RoutedEventArgs e) { string name; if (txtName.Text == "") { name = null; } else { name = txtName.Text; } string firstname; if (txtFirstname.Text == "") { firstname = null; } else { firstname = txtFirstname.Text; } string email; if (txtEmail.Text == "") { email = null; } else { email = txtEmail.Text; } string login; if (txtLoginUser.Text == "") { login = null; } else { login = txtLoginUser.Text; } string pwd; if (txtPwdUser.Text == "") { pwd = null; } else { pwd = txtPwdUser.Text; } string keyword; if (txtKeyword.Text == "") { keyword = null; } else { keyword = txtKeyword.Text; } mainVM.MyRegistered = new Registered(mainVM.MyForum.User.IdUser, (Status)cmbStatus.SelectedItem, (Training)cmbTraining.SelectedItem, name, firstname, email, login, pwd, keyword); List <ValidationError> lstErreur = mainVM.MyRegistered.Validate(); if (lstErreur.Count < 1) { if (mainVM.MyRegistered.SaveUser(mainVM.MyRegistered, mainVM.MyForum.TokenUser)) { mainVM.MyForum.TokenUser = null; Token token = new Token(0, login, pwd, 0); DALClient dal = new DALClient(); DALWSR_Result r = dal.LoginAsync(token, CancellationToken.None); if (r.Data != null) { token = (Token)r.Data; } else { mainVM.MessagePopup = "Problème de connexion."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Problème de connexion"); //essai.ShowAsync(); } if (token.Valid != false) { mainVM.MyForum.TokenUser = token; mainVM.MyForum.User = mainVM.MyForum.User.GetInfoUser(token.IdUser); if (mainVM.MyForum.User != null) { mainVM.MyRegistered = mainVM.MyForum.User; mainVM.IsLogged = true; mainVM.InfoUser = false; } else { mainVM.MessagePopup = "Problème de connexion."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Problème de connexion"); //essai.ShowAsync(); } } else { mainVM.MyForum.TokenUser = null; mainVM.IsLogged = false; mainVM.MessagePopup = "Problème d'authentification, veuillez contacter l'administrateur."; ModalPopupError.IsOpen = true; //MessageDialog essai = new MessageDialog("Problème d'authentification, veuillez contacter l'administrateur"); //essai.ShowAsync(); } } } else { string str = string.Empty; foreach (var item in lstErreur) { str = str + item.Information + Environment.NewLine; } mainVM.MessagePopup = str; ModalPopupError.IsOpen = true; //MessageDialog errorRegister = new MessageDialog(str); //errorRegister.ShowAsync(); } }
private void cmdConnect_Click(object sender, RoutedEventArgs e) { /*Token token = new Token(0, txtLogin.Text, txtPwd.Password, 0); * * DALClient dal = new DALClient(); * DALWSR_Result r = dal.LoginAsync(token, CancellationToken.None); * if(r.Data != null) * { * token = (Token)r.Data; * } * if(token.Valid != false) * { * mainVM.MyForum.TokenUser = token; * mainVM.MyForum.User = mainVM.MyForum.User.GetInfoUser(token.IdUser); * mainVM.MyRegistered = mainVM.MyForum.User; * mainVM.IsLogged = true; * Frame.Navigate(typeof(MainPage), DataContext); * } * else * { * mainVM.MyForum.TokenUser = null; * mainVM.IsLogged = false; * //todo montrer message comme quoi le login/mdp est incorrect * }*/ Token token = new Token(0, txtLogin.Text, txtPwd.Password, 0); DALClient dal = new DALClient(); DALWSR_Result r = dal.LoginAsync(token, CancellationToken.None); if (r.Data != null) { token = (Token)r.Data; } else { MessageDialog essai = new MessageDialog("Problème de connexion"); essai.ShowAsync(); } if (token.Valid != false) { mainVM.MyForum.TokenUser = token; mainVM.MyForum.User = mainVM.MyForum.User.GetInfoUser(token.IdUser); if (mainVM.MyForum.User != null) { mainVM.MyRegistered = mainVM.MyForum.User; mainVM.IsLogged = true; Frame.Navigate(typeof(MainPage), DataContext); } else { MessageDialog essai = new MessageDialog("Problème de connexion"); essai.ShowAsync(); } } else { mainVM.MyForum.TokenUser = null; mainVM.IsLogged = false; MessageDialog essai = new MessageDialog("Login ou mot de passe incorrect"); essai.ShowAsync(); } }