life quality changes
- refactored SurveyController.cs - added ProducesResponseType to every endpoint in every controller - remade mappers
This commit is contained in:
parent
9e50b97bc9
commit
6692a91821
11 changed files with 146 additions and 93 deletions
|
|
@ -9,10 +9,13 @@ namespace SurveyBackend.Services.Services;
|
|||
public class QuestionService : IQuestionService
|
||||
{
|
||||
private readonly IQuestionRepository _questionRepository;
|
||||
private readonly ISurveyRepository _surveyRepository;
|
||||
|
||||
public QuestionService(IQuestionRepository questionRepository, IUserContext userContext)
|
||||
public QuestionService(IQuestionRepository questionRepository, ISurveyRepository surveyRepository,
|
||||
IUserContext userContext)
|
||||
{
|
||||
_questionRepository = questionRepository;
|
||||
_surveyRepository = surveyRepository;
|
||||
}
|
||||
|
||||
public async Task AddQuestionAsync(QuestionBase question)
|
||||
|
|
@ -49,6 +52,12 @@ public class QuestionService : IQuestionService
|
|||
|
||||
public async Task<IEnumerable<QuestionBase>> GetQuestionsBySurveyIdAsync(int surveyId)
|
||||
{
|
||||
var survey = await _surveyRepository.GetByIdAsync(surveyId);
|
||||
if (survey is null)
|
||||
{
|
||||
throw new NotFoundException("Survey not found");
|
||||
}
|
||||
|
||||
return await _questionRepository.GetQuestionsBySurveyId(surveyId);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue