Exemplo n.º 1
0
 public IActionResult Post([FromBody] QuizLibrary.Question question)
 {
     NewQuiz = new QuizManager();
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     NewQuiz.AddQuestion(question);
     return(Ok(question.Question_statement));
 }
Exemplo n.º 2
0
 public IActionResult Get(String id)
 {
     NewQuiz = new QuizManager();
     QuizLibrary.Question GotQuestion = NewQuiz.GetQuestionById(id);
     if (GotQuestion == null)
     {
         return(NotFound());
     }
     return(Ok(GotQuestion));
 }
Exemplo n.º 3
0
        public IActionResult Put(JObject jObject)
        {
            NewQuiz = new QuizManager();
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            dynamic json = jObject;

            //Question question = json.question.ToObject<Question>();
            //string new_ques = json.new_ques;
            QuizLibrary.Question new_ques = json.ToObject <QuizLibrary.Question>();

            //int index = json.index;

            if (NewQuiz.UpdateQuestion(new_ques))
            {
                Console.WriteLine("success");
            }

            return(Ok());
        }