예제 #1
0
        public IActionResult Update(UpdateMCQuestionDto 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.Update(dto);
                    return(Redirect("~/Quiz/Questions?Id=" + (dto.QuizId)));
                }
            }
            return(View(dto));
        }
예제 #2
0
 public IActionResult Update([FromForm] UpdateMCQuestionDto dto)
 {
     _service.Update(dto);
     return(Ok(GetResponse()));
 }