We just did an excellent job with our quizzes, but it's still not enough to allow our users to actually create--or even take!--a quiz; we're still missing questions, answers, and results.
In the following paragraphs, we'll do our best to bring them up to speed.
Remember all those controllers that we set up back in Chapter 2, Backend with .NET Core? We have been neglecting them for a while, with the sole exception of the QuizController
; it's definitely time to atone.
Let's start with QuestionController
. Here's the code that will put it back on track (new/updated lines are highlighted):
using System;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using TestMakerFreeWebApp.ViewModels;
using System.Collections.Generic;
using System.Linq;
using TestMakerFreeWebApp.Data;
using Mapster;
namespace TestMakerFreeWebApp.Controllers
{
[Route("api/[controller]")]
public class QuestionController : Controller
{
...