From 2b5f468b84899072a952b6a254e0331dae2bb6fe Mon Sep 17 00:00:00 2001 From: shept Date: Wed, 16 Apr 2025 21:57:56 +0500 Subject: [PATCH] can create Surveys for fun now --- .../SurveyBackend.API/Controllers/SurveyController.cs | 8 +++++++- .../SurveyBackend.API/DTOs/Survey/CreateSurveyDTO.cs | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 SurveyBackend/SurveyBackend.API/DTOs/Survey/CreateSurveyDTO.cs diff --git a/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs b/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs index 6209e8c..5a96f0b 100644 --- a/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs +++ b/SurveyBackend/SurveyBackend.API/Controllers/SurveyController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using SurveyBackend.DTOs.Survey; using SurveyLib.Core.Models; using SurveyLib.Core.Services; using SurveyLib.Infrastructure.EFCore.Services; @@ -31,8 +32,13 @@ public class SurveyController : ControllerBase } [HttpPost] - public async Task Post([FromBody] Survey survey) + public async Task Post([FromBody] CreateSurveyDTO dto) { + var survey = new Survey + { + Title = dto.Title, + Description = dto.Description, + }; await _surveyService.AddSurveyAsync(survey); return Ok(); } diff --git a/SurveyBackend/SurveyBackend.API/DTOs/Survey/CreateSurveyDTO.cs b/SurveyBackend/SurveyBackend.API/DTOs/Survey/CreateSurveyDTO.cs new file mode 100644 index 0000000..5b25182 --- /dev/null +++ b/SurveyBackend/SurveyBackend.API/DTOs/Survey/CreateSurveyDTO.cs @@ -0,0 +1,7 @@ +namespace SurveyBackend.DTOs.Survey; + +public class CreateSurveyDTO +{ + public required string Title { get; set; } + public string Description { get; set; } = string.Empty; +} \ No newline at end of file