diff --git a/Dentizone.Application/Services/QAService.cs b/Dentizone.Application/Services/QAService.cs index 7a06d7e..fcb1db1 100644 --- a/Dentizone.Application/Services/QAService.cs +++ b/Dentizone.Application/Services/QAService.cs @@ -102,17 +102,15 @@ public async Task> GetQuestionsForPostAsync(string var questions = await questionRepository.FindAllBy( q => q.PostId == postId && !q.IsDeleted, includes); - if (questions == null || !questions.Any()) - { - return []; - } + return mapper.Map>(questions); } public async Task UpdateAnswerAsync(string answerId, UpdateAnswerDto dto) { - var answer = await answerRepository.GetByIdAsync(answerId); + var answer = await answerRepository.GetByIdAsync(answerId) ?? + throw new NotFoundException("No Answer with this ID"); answer.Text = dto.Text; await answerRepository.UpdateAsync(answer); } diff --git a/Dentizone.Presentaion/Controllers/QAController.cs b/Dentizone.Presentaion/Controllers/QAController.cs index c48a7fa..d156793 100644 --- a/Dentizone.Presentaion/Controllers/QAController.cs +++ b/Dentizone.Presentaion/Controllers/QAController.cs @@ -21,6 +21,7 @@ public async Task AskQuestion([FromBody] CreateQuestionDto dto) } [HttpGet("questions/{postId}")] + [AllowAnonymous] public async Task GetQuestionsForPost(string postId) { var questions = await qaService.GetQuestionsForPostAsync(postId);