Exemplo n.º 1
0
        public async Task Create(CreateMCQuestionDto dto)
        {
            var mcq = _mapper.Map <MCQuestionDbEntity>(dto);

            if (dto.AttachmentURL != null)
            {
                mcq.AttachmentURL = await _fileService.SaveFile(dto.AttachmentURL, "Attachments");

                await _DB.MCQustions.AddAsync(mcq);
            }
            else
            {
                _DB.MCQustions.Add(mcq);
            }
            _DB.SaveChanges();
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 public IActionResult Create([FromForm] CreateMCQuestionDto dto)
 {
     _service.Create(dto);
     return(Ok(GetResponse()));
 }