using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using SurveyBackend.Mappers; using SurveyLib.Core.Services; namespace SurveyBackend.Controllers; [ApiController] public class AnswerController : ControllerBase { private readonly IAnswerService _answerService; public AnswerController(IAnswerService answerService) { _answerService = answerService; } [Authorize] [HttpGet] [Route("api/questions/{id:int}/answers")] public async Task GetAnswersByQuestionId(int id) { var models = await _answerService.GetAnswersByQuestionIdAsync(id); var result = models.Select(AnswerMapper.ModelToOutputDto); return Ok(result); } [Authorize] [HttpGet] [Route("api/completions/{id:int}/answers")] public async Task GetAnswersByCompletionId(int id) { var models = await _answerService.GetAnswersByCompletionIdAsync(id); var result = models.Select(AnswerMapper.ModelToOutputDto); return Ok(result); } }