Пример #1
0
        public JsonResult Delete(int id)
        {
            QuizRepository.Delete(id);
            QuizRepository.Save();

            return(new JsonResult()
            {
                Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #2
0
        public ActionResult Create(Quiz model)
        {
            if (ModelState.IsValid)
            {
                QuizRepository.Insert(model);
                QuizRepository.Save();
                return(RedirectToAction("Index"));
            }

            FillDropdownValues();
            return(View(model));
        }
Пример #3
0
        public JsonResult DeleteQuestion(int id, int quizId)
        {
            var modelQuestion = QuestionRepository.Find(id);
            var modelQuiz     = QuizRepository.Find(quizId);

            modelQuiz.Questions.Remove(modelQuestion);
            QuizRepository.Update(modelQuiz);
            QuizRepository.Save();

            return(new JsonResult()
            {
                Data = "OK", JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #4
0
        public ActionResult EditPost(Quiz formModel)
        {
            if (ModelState.IsValid)
            {
                var modelDb = QuizRepository.Find(formModel.ID);
                if (this.TryUpdateModel(modelDb))
                {
                    QuizRepository.Update(modelDb);
                    QuizRepository.Save();

                    return(RedirectToAction("Index"));
                }
            }

            FillDropdownValues();
            return(View(formModel));
        }
Пример #5
0
        public ActionResult AddQuestionPost(Quiz formModel, int Question)
        {
            if (ModelState.IsValid)
            {
                var modelDb       = QuizRepository.Find(formModel.ID);
                var modelQuestion = QuestionRepository.Find(Question);
                modelDb.Questions.Add(modelQuestion);
                if (this.TryUpdateModel(modelDb))
                {
                    QuizRepository.Update(modelDb);
                    QuizRepository.Save();

                    //return RedirectToAction("Index");
                }
            }
            FillDropdownValues();
            return(View(formModel));
        }