Ejemplo n.º 1
0
        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);
                }
            });
        }
Ejemplo n.º 2
0
        public static void HandleException(Exception ex)
        {
            Logger.Error(ex);
            ErrorWindow win = new ErrorWindow();

            win.ShowDialog();
            ApplicationMessage.Send(MessageType.CloseApp, MessageType.CloseApp.ToString());
        }
Ejemplo n.º 3
0
 private void CreateRunCommand()
 {
     this.run = new RelayCommand <TestSet>(test =>
     {
         try
         {
             ApplicationMessage.Send(MessageType.TestRun, test);
         }
         catch (Exception ex)
         {
             ApplicationErrorHandler.HandleException(ex);
         }
     });
 }
Ejemplo n.º 4
0
 private void CreateEditCommand()
 {
     try
     {
         this.edit = new RelayCommand <TestSet>(test =>
         {
             ApplicationMessage.Send(MessageType.TestEdit, test);
         });
     }
     catch (Exception ex)
     {
         ApplicationErrorHandler.HandleException(ex);
     }
 }
Ejemplo n.º 5
0
 private void CreateAddCommand()
 {
     try
     {
         this.add = new RelayCommand(() =>
         {
             ApplicationMessage.Send <string>(Messages.Enum.MessageType.TestAdd, "Add test");
         });
     }
     catch (Exception ex)
     {
         ApplicationErrorHandler.HandleException(ex);
     }
 }
Ejemplo n.º 6
0
 private void CreateDisplayQuestionsCommand()
 {
     this.displayQuestions = new RelayCommand <TestSet>(test =>
     {
         try
         {
             ApplicationMessage.Send(MessageType.TestQuestionsDisplay, test);
         }
         catch (Exception ex)
         {
             ApplicationErrorHandler.HandleException(ex);
         }
     });
 }
Ejemplo n.º 7
0
 private void CreateCancelCommand()
 {
     this.cancel = new RelayCommand(() =>
     {
         try
         {
             ApplicationMessage.Send(MessageType.TestsDisplay, MessageType.TestsDisplay.ToString());
         }
         catch (Exception ex)
         {
             ApplicationErrorHandler.HandleException(ex);
         }
     });
 }
Ejemplo n.º 8
0
 private void CreatePreviousCommand()
 {
     try
     {
         this.previousCommand = new RelayCommand(() =>
         {
             ApplicationMessage.Send(MessageType.PreviousViewDisplay, "Display previous view");
         });
     }
     catch (Exception ex)
     {
         ApplicationErrorHandler.HandleException(ex);
     }
 }
Ejemplo n.º 9
0
 private void CreateAddCategoryCommand()
 {
     try
     {
         this.addCategory = new RelayCommand(() =>
         {
             ApplicationMessage.Send(MessageType.CategoryAdd, MessageType.CategoryAdd.ToString());
         });
     }
     catch (Exception ex)
     {
         ApplicationErrorHandler.HandleException(ex);
     }
 }
Ejemplo n.º 10
0
 private void CreateEditCategoryCommand()
 {
     this.editCategory = new RelayCommand <Category>(category =>
     {
         try
         {
             ApplicationMessage.Send(MessageType.CategoryEdit, category);
         }
         catch (Exception ex)
         {
             ApplicationErrorHandler.HandleException(ex);
         }
     });
 }
Ejemplo n.º 11
0
        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);
                }
            });
        }
Ejemplo n.º 12
0
 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);
     }
 }
Ejemplo n.º 13
0
        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);
                }
            });
        }