can create Surveys for fun now

This commit is contained in:
Вячеслав 2025-04-16 21:57:56 +05:00
parent 77a49ff49b
commit 2b5f468b84
2 changed files with 14 additions and 1 deletions

View file

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SurveyBackend.DTOs.Survey;
using SurveyLib.Core.Models; using SurveyLib.Core.Models;
using SurveyLib.Core.Services; using SurveyLib.Core.Services;
using SurveyLib.Infrastructure.EFCore.Services; using SurveyLib.Infrastructure.EFCore.Services;
@ -31,8 +32,13 @@ public class SurveyController : ControllerBase
} }
[HttpPost] [HttpPost]
public async Task<IActionResult> Post([FromBody] Survey survey) public async Task<IActionResult> Post([FromBody] CreateSurveyDTO dto)
{ {
var survey = new Survey
{
Title = dto.Title,
Description = dto.Description,
};
await _surveyService.AddSurveyAsync(survey); await _surveyService.AddSurveyAsync(survey);
return Ok(); return Ok();
} }

View file

@ -0,0 +1,7 @@
namespace SurveyBackend.DTOs.Survey;
public class CreateSurveyDTO
{
public required string Title { get; set; }
public string Description { get; set; } = string.Empty;
}