added existance check (not sure if it's working)

This commit is contained in:
Вячеслав 2025-05-31 01:41:54 +05:00
parent 9a7c74e307
commit a5aad09046
4 changed files with 78 additions and 13 deletions

View file

@ -22,7 +22,12 @@ public class QuestionService : IQuestionService
public async Task AddQuestionAsync(QuestionBase question)
{
// TODO: проверить существование опроса
var survey = await _surveyRepository.GetByIdAsync(question.SurveyId);
if (survey is null)
{
throw new NotFoundException("Survey not found");
}
await _questionRepository.AddAsync(question);
}