Exemplo n.º 1
0
        public async Task DeleteQuestion(int questionId)
        {
            await reactionRepository.DeleteReactionsForPost(questionId, PostType.QUESTION);

            var anwsers = await applicationDbContext.Answers.Where(x => x.QuestionID == questionId).ToListAsync();

            anwsers.ForEach(x =>
            {
                applicationDbContext.Answers.Remove(x);
                reactionRepository.DeleteReactionsForPost(x.Id, PostType.ANWSER);
            });
            var q = await getQuestion(questionId);

            applicationDbContext.Questions.Remove(q);

            await applicationDbContext.SaveChangesAsync();
        }