add completions methods (not final)
This commit is contained in:
parent
58b5b2b17d
commit
c2f6ba6dde
4 changed files with 23 additions and 5 deletions
|
|
@ -26,14 +26,18 @@ public class CompletionController : ControllerBase
|
|||
[Authorize]
|
||||
public async Task<IActionResult> GetCompletionsAsync(int surveyId)
|
||||
{
|
||||
return NotFound();
|
||||
var models = await _completionService.GetCompletionsBySurveyIdAsync(surveyId);
|
||||
var result = models.Select(CompletionMapper.ModelToOutputDto);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet("{id:int}")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> GetCompletionAsync(int id)
|
||||
{
|
||||
return NotFound();
|
||||
var model = await _completionService.GetCompletionByIdAsync(id);
|
||||
var result = CompletionMapper.ModelToOutputDto(model);
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ namespace SurveyBackend.DTOs.Completion;
|
|||
|
||||
public class CompletionOutputDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SurveyId { get; set; }
|
||||
public int? CompletedBy { get; set; }
|
||||
public DateTime FinishedAt { get; set; }
|
||||
public List<AnswerOutputDto> Answers { get; set; }
|
||||
}
|
||||
|
|
@ -14,8 +14,9 @@ public static class CompletionMapper
|
|||
|
||||
public static CompletionOutputDto ModelToOutputDto(Completion model) => new CompletionOutputDto
|
||||
{
|
||||
Id = model.Id,
|
||||
SurveyId = model.SurveyId,
|
||||
CompletedBy = model.CompletedBy,
|
||||
FinishedAt = model.FinishedAt,
|
||||
Answers = model.Answers.Select(AnswerMapper.ModelToOutputDto).ToList(),
|
||||
FinishedAt = model.FinishedAt
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue