コード例 #1
0
ファイル: CategoryListVM.cs プロジェクト: ThijsReba/KwisSpel
 public void DeleteCategory()
 {
     using (var context = new QuizDatabaseEntities())
     {
         var category = SelectedCategory.ToModel();
         //Even aan entity framework laten weten dat we dingen hebben aangepast!
         context.Entry(category).State = EntityState.Deleted;
         context.SaveChanges();
     }
     Categories.Remove(SelectedCategory);
 }
コード例 #2
0
ファイル: QuizListVM.cs プロジェクト: ThijsReba/KwisSpel
 public void DeleteQuiz()
 {
     using (var context = new QuizDatabaseEntities())
     {
         var quiz = SelectedQuiz.ToModel();
         //Even aan entity framework laten weten dat we dingen hebben aangepast!
         context.Entry(quiz).State = EntityState.Deleted;
         //context.Quizs.Remove(quiz);
         context.SaveChanges();
     }
     Quizes.Remove(SelectedQuiz);
 }
コード例 #3
0
ファイル: AddQuizVM.cs プロジェクト: ThijsReba/KwisSpel
        private void AddQuiz()
        {
            _quizList.Quizes.Add(Quiz);

            using (var context = new QuizDatabaseEntities())
            {
                context.Quizs.Add(Quiz.ToModel());
                context.SaveChanges();
            }

            _quizList.HideAddQuiz();
        }
コード例 #4
0
ファイル: AddQuestionVM.cs プロジェクト: ThijsReba/KwisSpel
        private void AddQuestion()
        {
            _questionList.Questions.Add(Question);

            using (var context = new QuizDatabaseEntities())
            {
                context.Questions.Add(Question.ToModel());
                context.SaveChanges();
            }

            _questionList.HideAddQuestion();
        }
コード例 #5
0
        private void AddCategory()
        {
            _categoryList.Categories.Add(Category);

            using (var context = new QuizDatabaseEntities())
            {
                context.Categories.Add(Category.ToModel());
                context.SaveChanges();
            }

            _categoryList.HideAddCategory();
        }
コード例 #6
0
ファイル: EditCategoryVM.cs プロジェクト: ThijsReba/KwisSpel
        private void Save(EditCategoryWindow window)
        {
            using (var context = new QuizDatabaseEntities())
            {
                var category = Category.ToModel();
                //Even aan entity framework laten weten dat we dingen hebben aangepast!
                context.Entry(category).State = EntityState.Modified;
                context.SaveChanges();
            }

            window.Hide();
        }
コード例 #7
0
        private void Save(EditQuizWindow window)
        {
            using (var context = new QuizDatabaseEntities())
            {
                Quiz quiz = context.Quizs.Where(q => q.QuizId == Quiz.QuizId).First();
                quiz.Description = Quiz.Description;

                context.Entry(quiz).State = EntityState.Modified;
                context.SaveChanges();
            }
            window.Hide();
        }
コード例 #8
0
ファイル: EditQuestionVM.cs プロジェクト: ThijsReba/KwisSpel
        private void Save(EditQuestionWindow window)
        {
            using (var context = new QuizDatabaseEntities())
            {
                Question question = context.Questions.Where(q => q.QuestionId == Question.QuestionId).First();
                question.CategoryName = Question.CategoryName;
                question.Description  = Question.Description;

                context.Entry(question).State = EntityState.Modified;
                context.SaveChanges();
            }
            window.Hide();
        }
コード例 #9
0
ファイル: QuestionListVM.cs プロジェクト: ThijsReba/KwisSpel
        public QuestionListVM()
        {
            using (var context = new QuizDatabaseEntities())
            {
                var questions = context.Questions
                                .Include("Category")
                                .ToList()
                                .Select(e => new QuestionVM(e));

                Questions = new ObservableCollection <QuestionVM>(questions);
            }

            ShowAddQuestionCommand  = new RelayCommand(ShowAddQuestion, CanShowAddQuestion);
            ShowEditQuestionCommand = new RelayCommand(ShowEditQuestionWindow);
        }
コード例 #10
0
ファイル: CategoryListVM.cs プロジェクト: ThijsReba/KwisSpel
        public CategoryListVM()
        {
            using (var context = new QuizDatabaseEntities())
            {
                var categories = context.Categories
                                 .ToList()
                                 .Select(a => new CategoryVM(a));

                Categories = new ObservableCollection <CategoryVM>(categories);
            }

            ShowCategoryManagementCommand = new RelayCommand(ShowCategoryManagement, CanShowCategoryManagement);

            ShowAddCategoryCommand  = new RelayCommand(ShowAddCategory, CanShowAddCategory);
            ShowEditCategoryCommand = new RelayCommand(ShowEditCategoryWindow);
            DeleteCategoryCommand   = new RelayCommand(DeleteCategory);
        }
コード例 #11
0
ファイル: QuizListVM.cs プロジェクト: ThijsReba/KwisSpel
        public QuizListVM()
        {
            using (var context = new QuizDatabaseEntities())
            {
                var quizs = context.Quizs
                            .Include("Questions")
                            .ToList()
                            .Select(a => new QuizVM(a));

                Quizes = new ObservableCollection <QuizVM>(quizs);
            }

            ShowQuizManagementCommand = new RelayCommand(ShowQuizManagement, CanShowQuizManagement);

            ShowAddQuizCommand  = new RelayCommand(ShowAddQuiz, CanShowAddQuiz);
            ShowEditQuizCommand = new RelayCommand(ShowEditQuizWindow);
            DeleteQuizCommand   = new RelayCommand(DeleteQuiz);

            ShowQuestionManagementCommand = new RelayCommand(ShowQuestionManagement, CanShowQuestionManagement);
            ShowCategoryManagementCommand = new RelayCommand(ShowCategoryManagement, CanShowCategoryManagement);
        }