public ResultTable(object mainWindow) { InitializeComponent(); SetResultTable(App.CurrentUser); performWindow = mainWindow as PerformWindow; constructorWindow = mainWindow as ConstructorWindow; }
public TestFinisher(PerformWindow perform, Test test, Progress progress) { InitializeComponent(); performWindow = perform; DataContext = progress; markInPercent = GetResultInPercent((double)progress.Mark, (double)test.TotalWeight); ShowResult(currentTest = test); }
public TestRunner(PerformWindow perform, Test test) { InitializeComponent(); currentTest = test; performWindow = perform; db = new AppDbContext(); userAnswers = new List <UserAnswer>(); progress = new Progress() { UserId = App.CurrentUser.Id, Username = App.CurrentUser.Username, TestId = test.Id, TestTitle = test.Title, TestCreator = test.Creator }; }
public LevelWindow(PerformWindow perform) { InitializeComponent(); performWindow = perform; DataContext = App.CurrentUser; }
private void Login() { try { string username = logLoginTextBox.Text; string password = logPasswordTextBox.Password; LoginModel loginModel = new LoginModel() { Login = username, Password = password }; if (Validation.TryValidateObject(loginModel, logLoginTextBox, logPasswordTextBox, null)) { using (AppDbContext db = new AppDbContext()) { var user = db.Users.FirstOrDefault(u => u.Username == username); if (user != null) { if (SaltedHash.Verify(user.Salt, user.Hash, password)) { App.CurrentUser = user; if (user.IsTeacher) { ConstructorWindow constructorWindow = new ConstructorWindow(); Close(); constructorWindow.Show(); } else { PerformWindow performWindow = new PerformWindow(); Close(); performWindow.Show(); if (user.Level == null) { LevelWindow levelWindow = new LevelWindow(performWindow); levelWindow.Show(); } } } else { logPasswordTextBox.BorderBrush = new SolidColorBrush(Colors.Red); logPasswordTextBox.ToolTip = new ToolTip() { Content = "Wrong password" }; } } else { logLoginTextBox.BorderBrush = new SolidColorBrush(Colors.Red); logLoginTextBox.ToolTip = new ToolTip() { Content = "User with this username is not found" }; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); } }