public void GetConfig() { try { // Open data access object using racenetdbContext db = new(); DataAccessProvider dataAccessProvider = new(db); //Get the current category CurrentCategory = dataAccessProvider.GetCurrentCategory(); // Get the current mode Mode = dataAccessProvider.GetMode(); // Reset all the view models CurrentPairViewModel = new CurrentPairViewModel(CurrentCategory, Mode); // Checks if the qualifying category's id matches the active category id if (QualifyingViewModel == null || QualifyingViewModel.Category.Id == CurrentCategory.Id) { QualifyingViewModel = new QualifyingViewModel(CurrentCategory); } } catch (Exception) { throw; } }
/// <summary> /// Default constructor /// </summary> public MainWindowViewModel() { // Data access object DataAccessProvider dataAccessProvider = new(new racenetdbContext()); // Get the current config GetConfig(); // Create all the subsection view models RunlogViewModel = new RunlogViewModel(); QualifyingViewModel = new QualifyingViewModel(CurrentCategory); RunHistoryViewModel = new RunHistoryViewModel(CurrentCategory.Id); // Start a background thread for monitoring rn_runlog changes var ts = new ThreadStart(ListenForUpdates); var predictionsThread = new Thread(ts); predictionsThread.Start(); }