i'm sorry guys it's stupid commit...

This commit is contained in:
Вячеслав 2025-05-31 00:05:45 +05:00
parent 77cfacb95e
commit 4b4739ce89
13 changed files with 174 additions and 1 deletions

View file

@ -0,0 +1,48 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SurveyBackend.Contexts;
using SurveyBackend.Core.Contexts;
using SurveyBackend.DTOs.Completion;
using SurveyBackend.Mappers;
using SurveyLib.Core.Models;
using SurveyLib.Core.Services;
namespace SurveyBackend.Controllers;
[ApiController]
[Route("api/surveys/{surveyId:int}/completions")]
public class CompletionController : ControllerBase
{
private readonly ICompletionService _completionService;
private readonly IUserContext _userContext;
public CompletionController(ICompletionService completionService, IUserContext userContext)
{
_completionService = completionService;
_userContext = userContext;
}
[HttpGet]
[Authorize]
public async Task<IActionResult> GetCompletionsAsync(int surveyId)
{
return NotFound();
}
[HttpGet("{id:int}")]
[Authorize]
public async Task<IActionResult> GetCompletionAsync(int id)
{
return NotFound();
}
[HttpPost]
[AllowAnonymous]
public async Task<IActionResult> PostCompletionAsync([FromBody] CompletionCreateDto dto, [FromRoute] int surveyId)
{
var userId = _userContext.NullableUserId;
var model = CompletionMapper.CreateDtoToModel(dto, surveyId, userId);
await _completionService.AddCompletionAsync(model);
return Ok();
}
}