public TestSetEditViewModel() { try { this.selectedTest = new TestSet(); this.testSetsModel = BootStrapper.Resolve <ITestSetsModel>(); this.categoriesModel = BootStrapper.Resolve <ICategoriesModel>(); this.items = new ObservableCollection <TestItem>(); if (this.selectedTest.Items != null) { foreach (TestItem item in this.selectedTest.Items) { this.items.Add(item); } } this.categories = this.categoriesModel.GetAll(); this.languages = this.testSetsModel.GetAllLanguages(); this.SelectedLanguage = TestLanguage.English; } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
private void CreateQuestionEditCommand() { this.questionEdit = new RelayCommand <TestItem>(item => { try { TestItemEditView win = new TestItemEditView(item); if (win.ShowDialog() ?? false) { this.selectedItem = item; this.items.Remove(this.selectedItem); item.Question = win.Question; item.Answer = win.Answer; item.Example = win.Example; this.items.Add(item); } this.SelectedQuestion = null; base.RaisePropertyChanged("SelectedQuestion"); base.RaisePropertyChanged("Questions"); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateFilterByCategoryCommand() { this.filterByCategory = new RelayCommand(() => { try { if (this.selectedCategory == null) { return; } this.tests = new ObservableCollection <TestSet>(); foreach (TestSet test in this.testSetsModel.GetAll().Where(x => x.Category.Id == this.selectedCategory.Id)) { this.tests.Add(test); } base.RaisePropertyChanged("Tests"); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateQuestionAddCommand() { this.questionAdd = new RelayCommand(() => { try { TestItemEditView win = new TestItemEditView(); if (win.ShowDialog() ?? false) { TestItem item = new TestItem() { Question = win.Question, Answer = win.Answer, Example = win.Example }; this.AddItem(item); } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateSaveCommand() { this.save = new RelayCommand(() => { try { this.selectedTest.Items.Clear(); foreach (TestItem item in this.items) { this.selectedTest.Items.Add(item); } if (this.selectedTest.Id > 0) { this.testSetsModel.Update(this.selectedTest); } else { this.testSetsModel.Add(this.selectedTest); } ApplicationMessage.Send(MessageType.TestsDisplay, MessageType.TestsDisplay.ToString()); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
public ScoresViewModel() { try { this.model = BootStrapper.Resolve <IScoreModel>(); this.scores = this.model.GetAll(); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
public CategoriesViewModel(ICategoriesModel model) { try { this.model = model; this.GetAllCategories(); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
public RunnerTestSetViewModel() { try { this.wrongAnswers = new List <TestItem>(); this.testSetsModel = BootStrapper.Resolve <ITestSetsModel>(); this.scoreModel = BootStrapper.Resolve <IScoreModel>(); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
public TestSetsViewModel() { try { this.testSetsModel = BootStrapper.Resolve <ITestSetsModel>(); this.categoriesModel = BootStrapper.Resolve <ICategoriesModel>(); this.tests = this.testSetsModel.GetAll(); this.categories = this.categoriesModel.GetAll(); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
private void CreateDisplayQuestionsCommand() { this.displayQuestions = new RelayCommand <TestSet>(test => { try { ApplicationMessage.Send(MessageType.TestQuestionsDisplay, test); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateAddCommand() { try { this.add = new RelayCommand(() => { ApplicationMessage.Send <string>(Messages.Enum.MessageType.TestAdd, "Add test"); }); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
private void CreateEditCommand() { try { this.edit = new RelayCommand <TestSet>(test => { ApplicationMessage.Send(MessageType.TestEdit, test); }); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
private void CreateAddCategoryCommand() { try { this.addCategory = new RelayCommand(() => { ApplicationMessage.Send(MessageType.CategoryAdd, MessageType.CategoryAdd.ToString()); }); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
private void CreateRunCommand() { this.run = new RelayCommand <TestSet>(test => { try { ApplicationMessage.Send(MessageType.TestRun, test); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateEditCategoryCommand() { this.editCategory = new RelayCommand <Category>(category => { try { ApplicationMessage.Send(MessageType.CategoryEdit, category); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreatePreviousCommand() { try { this.previousCommand = new RelayCommand(() => { ApplicationMessage.Send(MessageType.PreviousViewDisplay, "Display previous view"); }); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
private void CreateCancelCommand() { this.cancel = new RelayCommand(() => { try { ApplicationMessage.Send(MessageType.TestsDisplay, MessageType.TestsDisplay.ToString()); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateCheckAnswerCommand() { this.checkAnswer = new RelayCommand(() => { try { if (string.IsNullOrEmpty(this.userAnswer)) { return; } if (this.userAnswer.ToUpper() != this.items[this.questionNumber].Answer.ToUpper()) { this.wrongAnswers.Add(this.items[this.questionNumber]); CorrectAnswerWindow win = new CorrectAnswerWindow(this.items[this.questionNumber]); win.ShowDialog(); } this.questionNumber++; base.RaisePropertyChanged("Score"); if (this.questionNumber == this.items.Count) { WrongAnswersWindow win = new WrongAnswersWindow(this.wrongAnswers); win.ShowDialog(); decimal score = (this.questionNumber - this.wrongAnswers.Count) / (decimal)this.questionNumber; this.scoreModel.SaveScore(new Score() { ScoreValue = score, TestHeaderId = this.test.Id }); ApplicationMessage.Send(MessageType.TestsDisplay, "Display tests"); return; } base.RaisePropertyChanged("Question"); this.userAnswer = string.Empty; base.RaisePropertyChanged("Answer"); base.RaisePropertyChanged("QuestionNumber"); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateCancelCommand() { try { if (this.cancelCommand == null) { this.cancelCommand = new RelayCommand(() => { ApplicationMessage.Send(MessageType.CategoriesDisplay, MessageType.CategoriesDisplay.ToString()); }); } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }
private void CreateDeleteCategoryCommand() { this.deleteCategory = new RelayCommand <Category>(category => { try { DeleteConfirmWindow win = new DeleteConfirmWindow(); if (win.ShowDialog() == true) { this.model.Delete(category); this.GetAllCategories(); } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateDisplayPreviousCommand() { this.displayPreviousCommand = new RelayCommand(() => { try { if (this.questionNo > 0) { this.questionNo--; this.RaiseNavigationProperties(); this.DisplayFlashcards(); } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateDisplayNextCommand() { this.displayNextCommand = new RelayCommand(() => { try { if (this.questionNo < this.testHeader.Items.Count) { this.questionNo++; this.RaiseNavigationProperties(); this.DisplayFlashcards(); } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateDeleteCommand() { this.delete = new RelayCommand <TestSet>(test => { try { DeleteConfirmWindow win = new DeleteConfirmWindow(); if (win.ShowDialog() ?? false) { this.testSetsModel.Delete(test); this.tests = this.testSetsModel.GetAll(); base.RaisePropertyChanged("Tests"); } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateQuestionDeleteCommand() { this.questionDelete = new RelayCommand <TestItem>(item => { try { DeleteConfirmWindow win = new DeleteConfirmWindow(); if (win.ShowDialog() ?? false) { this.items.Remove(item); this.selectedItem = null; base.RaisePropertyChanged("Questions"); base.RaisePropertyChanged("SelectedQuestion"); base.RaisePropertyChanged("QuestionQuantity"); } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateSaveCommand() { this.saveCommand = new RelayCommand(() => { try { if (this.Category.Id > 0) { this.model.Update(this.Category); } else { this.model.Add(this.Category); } ApplicationMessage.Send(MessageType.CategoriesDisplay, MessageType.CategoriesDisplay.ToString()); } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
private void CreateImportCommand() { this.importCommand = new RelayCommand(() => { try { OpenFileDialog dlg = new OpenFileDialog(); Nullable <bool> result = dlg.ShowDialog(); if (result == true) { var itemsToImport = TestItemsImporter.ReadTestItems(dlg.FileName); foreach (var item in itemsToImport) { this.AddItem(item); } } } catch (Exception ex) { ApplicationErrorHandler.HandleException(ex); } }); }
protected void Application_Error(object sender, EventArgs e) { ApplicationErrorHandler.OnError <ErrorController>(((MvcApplication)sender).Context, Server.GetLastError(), "Error", "Index"); }
void MvcApplication_Error(object sender, EventArgs e) { //全局系统异常处理 ApplicationErrorHandler.ApplicationError(this); }