diff --git a/src/CrowdParlay.Social.Infrastructure.Persistence/Services/CommentsRepository.cs b/src/CrowdParlay.Social.Infrastructure.Persistence/Services/CommentsRepository.cs index b541283..923edf0 100644 --- a/src/CrowdParlay.Social.Infrastructure.Persistence/Services/CommentsRepository.cs +++ b/src/CrowdParlay.Social.Infrastructure.Persistence/Services/CommentsRepository.cs @@ -39,7 +39,7 @@ CASE WHEN COUNT(reply) > 0 THEN COLLECT(DISTINCT { } """, new { id = id.ToString() }); - + if (await data.PeekAsync() is null) throw new NotFoundException(); @@ -104,7 +104,13 @@ OPTIONAL MATCH (deepReplyAuthor:Author)<-[:AUTHORED_BY]-(deepReply:Comment)-[:RE }); if (await data.PeekAsync() is null) - throw new NotFoundException(); + { + return new Page + { + TotalCount = 0, + Items = Enumerable.Empty() + }; + } var record = await data.SingleAsync(); return record[0].Adapt>(); @@ -199,6 +205,15 @@ CASE WHEN COUNT(reply) > 0 THEN COLLECT(DISTINCT { count }); + if (await data.PeekAsync() is null) + { + return new Page + { + TotalCount = 0, + Items = Enumerable.Empty() + }; + } + var record = await data.SingleAsync(); return record[0].Adapt>(); });