public IActionResult Create(CreateMCQuestionDto dto) { List <string> options = new List <string>() { dto.A, dto.B, dto.C, dto.D }; if (ModelState.IsValid) { if (!options.Contains(dto.CorrectAnswer)) { ViewBag.ErrorMessage = "Correcr Answer should match one of the options"; return(View(dto)); } else { _service.Create(dto); return(Redirect("~/Quiz/Questions?Id=" + (dto.QuizId))); } } return(View(dto)); }
public IActionResult Create([FromForm] CreateMCQuestionDto dto) { _service.Create(dto); return(Ok(GetResponse())); }