Example #1
0
        public QuizListVM()
        {
            dbContext = new QuizDBAccess();
            var quizList = dbContext.All().Select(q => new QuizVM(q));

            SelectedQuiz = new QuizVM();
            Quizes       = new ObservableCollection <QuizVM>(quizList);
            SaveQuiz     = new RelayCommand(AddOrUpdateQuiz, canSave);
            DeleteQuiz   = new RelayCommand(RemoveQuiz, canRemove);
            ClearQuiz    = new RelayCommand(ClearSelectedQuiz, canClear);
        }
Example #2
0
        private void AddOrUpdateQuiz(object parameter)
        {
            if (_quiz.Id != 0) // Update selected quiz
            {
                dbContext.Update(_quiz.Quiz);
            }
            else // Add new quiz
            {
                Quizes.Add(_quiz);
                dbContext.Insert(_quiz.Quiz);
            }

            SelectedQuiz = new QuizVM();
        }
Example #3
0
 private void ClearSelectedQuiz(object parameter)
 {
     SelectedQuiz = new QuizVM();
 }
Example #4
0
 private void RemoveQuiz(object parameter)
 {
     dbContext.Delete(_quiz.Quiz);
     Quizes.Remove(_quiz);
     SelectedQuiz = new QuizVM();
 }