Ejemplo n.º 1
0
        public async Task <ActionResult <Quiz> > PostQuiz(AddQuiz quiz)
        {
            var theQuiz = new Quiz();

            theQuiz.UserId      = quiz.UserId;
            theQuiz.Title       = quiz.Quiz.Title;
            theQuiz.Description = quiz.Quiz.Description;

            var theQuestions = new List <Question>();

            foreach (var q in quiz.Question)
            {
                theQuestions.Add(new Question
                {
                    QuestionText    = q.QuestionText,
                    CorrectAnswer   = q.CorrectAnswer,
                    AlternativOne   = q.AlternativOne,
                    AlternativTwo   = q.AlternativTwo,
                    AlternativThree = q.AlternativThree,
                    AlternativFour  = q.AlternativFour
                });
            }
            theQuiz.Questions = theQuestions;

            _context.Quiz.Add(theQuiz);
            await _context.SaveChangesAsync();

            return(Ok(new
            {
                status = "success",
                message = "New quiz created!",
                quizId = theQuiz.QuizId,
                title = theQuiz.Title,
                description = theQuiz.Description
            }));
        }
Ejemplo n.º 2
0
 private void ShowAddQuiz()
 {
     addQuiz = new QuizVM(context);
     RaisePropertyChanged(null);
     addAddQuizWindow = new AddQuiz();
     addAddQuizWindow.Show();
 }