private void LoginExecuted(object sender, ExecutedRoutedEventArgs e) { User = null; Login = new LoginViewModel(); Login form = new Login(Login); if (form.ShowDialog() ?? false) { if (Login.Login == Parameters.BaseParameters.AdminLogin && Login.Password == Parameters.BaseParameters.AdminPassword) { User = new UserViewModel() { Name = "Administrateur", IsAdmin = true, }; } else { IEnumerable <int> years = TeacherModel.Login(Login.Login, Login.Password); LoadYears(years); TeacherViewModel teacher = TeacherModel.Login(Login.Login, Login.Password, SelectedYear); User = new UserViewModel() { Name = $"{teacher.Title} {teacher.FirstName} {teacher.LastName}", Teacher = teacher, }; } Parameters.LoadData(); Models.LoadData(); Reports.LoadData(); } }
private void ValidateCommandExecuted(object sender, ExecutedRoutedEventArgs e) { if ((MainViewModel.Instance.Parameters.BaseParameters.AdminLogin == Login && MainViewModel.Instance.Parameters.BaseParameters.AdminPassword == Password) || TeacherModel.Login(Login, Password).Any()) { ValidateEvent?.Invoke(); } else { MessageBox.Show("Erreur d'authentification", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } }