public async Task <ServiceResponse <List <GetTQuestionDTO> > > AddQuestion(AddTQuestionDTO newQuestion) { ServiceResponse <List <GetTQuestionDTO> > serviceResponse = new ServiceResponse <List <GetTQuestionDTO> >(); TestQuestion question = _mapper.Map <TestQuestion>(newQuestion); await _context.TestQuestions.AddAsync(question); await _context.SaveChangesAsync(); serviceResponse.Data = (_context.TestQuestions.Select(c => _mapper.Map <GetTQuestionDTO>(c))).ToList(); serviceResponse.Message = "New question successfully added"; return(serviceResponse); }
public async Task <IActionResult> AddQuestion(AddTQuestionDTO newQuestion) { return(Ok(await _courseService.AddQuestion(newQuestion))); }