private bool IsAccountValid(string login, string password) { try { using (var context = new DatabaseConnection()) { accounts account = context.accounts.Where(i => (i.LOGIN == login)).ToList().First(); if (IsPasswordValid(account, password, context)) { employees employee = context.employees.Find(account.ID); if (employee != null) // Employee found { this.account = account; switchToAdminPanel = IsAdminAccount(employee.ID, context); switchToCoachPanel = IsCoachAccount(employee.ID, context); } } else { MessageBox.Show("Invalid Password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (InvalidOperationException ex) { MessageBox.Show("Account not found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(switchToAdminPanel || switchToCoachPanel); }
public CoachWindowController(accounts account) { model = new CoachWindowModel(); view = new CoachWindow(model); model.Account = account; model.UpdateDataGrid(); view.SetDataGridsDataSource(model.DataGridItems); view.DisplayContent(); SubscribeWindowEvents(); }
private void SwitchController() { Controller newController = null; if (switchToCoachPanel) { newController = new CoachWindowController(account); } else if (switchToAdminPanel) { throw new NotImplementedException(); //TODO: switch to admin panel } newController.ShowView(); newController.ReturnControlRequest += OnReturnControl; switchToAdminPanel = false; switchToCoachPanel = false; account = null; }
private bool IsPasswordValid(accounts account, string password, DatabaseConnection context) { return((account.PASSWORD == password) ? true : false); }