return created objects
This commit is contained in:
parent
251810c973
commit
98b38f645f
2 changed files with 6 additions and 4 deletions
|
|
@ -47,11 +47,12 @@ public class QuestionController : ControllerBase
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> AddQuestion(CreateQuestionDto dto, [FromRoute] int surveyId)
|
public async Task<IActionResult> AddQuestion(CreateQuestionDto dto, [FromRoute] int surveyId)
|
||||||
{
|
{
|
||||||
var model = QuestionMapper.QuestionCreationToModel(dto, surveyId);
|
var model = QuestionMapper.QuestionCreationToModel(dto, surveyId);
|
||||||
await _questionService.AddQuestionAsync(model);
|
await _questionService.AddQuestionAsync(model);
|
||||||
return Created();
|
var result = QuestionMapper.ModelToQuestionDto(model);
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -65,14 +65,15 @@ public class SurveyController : ControllerBase
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(StatusCodes.Status201Created)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> Post([FromBody] CreateSurveyDto dto)
|
public async Task<IActionResult> Post([FromBody] CreateSurveyDto dto)
|
||||||
{
|
{
|
||||||
var userId = _userContext.UserId;
|
var userId = _userContext.UserId;
|
||||||
|
|
||||||
var survey = SurveyMapper.CreateDtoToModel(dto, userId);
|
var survey = SurveyMapper.CreateDtoToModel(dto, userId);
|
||||||
await _surveyService.AddSurveyAsync(survey);
|
await _surveyService.AddSurveyAsync(survey);
|
||||||
return Created();
|
var result = SurveyMapper.ModelToOutputDto(survey);
|
||||||
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue