fix changing question type
This commit is contained in:
parent
837f90db52
commit
e1f7540803
3 changed files with 22 additions and 2 deletions
|
|
@ -71,7 +71,8 @@ public class QuestionController : ControllerBase
|
|||
var question = QuestionMapper.QuestionUpdateToModel(dto, id);
|
||||
await _questionService.UpdateQuestionAsync(question);
|
||||
var updatedQuestion = await _questionService.GetQuestionByIdAsync(id);
|
||||
return Ok(updatedQuestion);
|
||||
var result = QuestionMapper.ModelToQuestionDto(updatedQuestion);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -69,16 +69,22 @@ public static class QuestionMapper
|
|||
{
|
||||
Id = questionId,
|
||||
Title = dto.Title,
|
||||
Discriminator = "TextQuestion",
|
||||
AnswerVariants = []
|
||||
},
|
||||
"singleanswerquestion" => new SingleAnswerQuestion
|
||||
{
|
||||
Id = questionId,
|
||||
Title = dto.Title,
|
||||
Discriminator = "SingleAnswerQuestion",
|
||||
AnswerVariants = []
|
||||
},
|
||||
"multipleanswerquestion" => new MultipleAnswerQuestion
|
||||
{
|
||||
Id = questionId,
|
||||
Title = dto.Title,
|
||||
Discriminator = "MultipleAnswerQuestion",
|
||||
AnswerVariants = []
|
||||
},
|
||||
_ => throw new BadRequestException("Unknown question type")
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue