From 98b38f645fee801eac27796f48e4ff661c5c7957 Mon Sep 17 00:00:00 2001 From: shept Date: Tue, 13 May 2025 18:08:51 +0500 Subject: [PATCH] return created objects --- .../SurveyBackend.API/Controllers/QuestionController.cs | 5 +++-- .../SurveyBackend.API/Controllers/SurveyController.cs | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs b/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs index e9ac6a0..d7240cc 100644 --- a/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs +++ b/SurveyBackend/SurveyBackend.API/Controllers/QuestionController.cs @@ -47,11 +47,12 @@ public class QuestionController : ControllerBase [Authorize] [HttpPost] [ProducesResponseType(StatusCodes.Status404NotFound)] - [ProducesResponseType(StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status200OK)] public async Task AddQuestion(CreateQuestionDto dto, [FromRoute] int surveyId) { var model = QuestionMapper.QuestionCreationToModel(dto, surveyId); await _questionService.AddQuestionAsync(model); - return Created(); + var result = QuestionMapper.ModelToQuestionDto(model); + return Ok(result); } } \ No newline at end of file diff --git a/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs b/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs index 24f1cd2..fcc3e13 100644 --- a/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs +++ b/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs @@ -65,14 +65,15 @@ public class SurveyController : ControllerBase /// [Authorize] [HttpPost] - [ProducesResponseType(StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status200OK)] public async Task Post([FromBody] CreateSurveyDto dto) { var userId = _userContext.UserId; var survey = SurveyMapper.CreateDtoToModel(dto, userId); await _surveyService.AddSurveyAsync(survey); - return Created(); + var result = SurveyMapper.ModelToOutputDto(survey); + return Ok(result); } ///