From 0ef9d0ad26a2a672597ecd7d4b42829b70b14d47 Mon Sep 17 00:00:00 2001 From: Berkan Sasmaz Date: Mon, 3 Jun 2024 11:01:56 +0300 Subject: [PATCH] fix comment query --- .../Comments/EfCoreCommentRepository.cs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 41cba8ca75..542188baf8 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -22,7 +22,8 @@ public class EfCoreCommentRepository : EfCoreRepository GetWithAuthorAsync(Guid id, + public virtual async Task GetWithAuthorAsync( + Guid id, CancellationToken cancellationToken = default) { var query = from comment in (await GetDbSetAsync()) @@ -66,8 +67,7 @@ public class EfCoreCommentRepository : EfCoreRepository c.Comment.IsApproved == true); - query.WhereIf(commentApproveState == (CommentApproveState.Approved | CommentApproveState.Waiting), c => c.Comment.IsApproved == true || c.Comment.IsApproved == null); + query = query.WhereIf(commentApproveState == CommentApproveState.Approved, c => c.Comment.IsApproved == true); + query = query.WhereIf(commentApproveState == (CommentApproveState.Approved | CommentApproveState.Waiting), c => c.Comment.IsApproved == true || c.Comment.IsApproved == null); return await query.ToListAsync(GetCancellationToken(cancellationToken)); } @@ -149,7 +148,9 @@ public class EfCoreCommentRepository : EfCoreRepository ExistsAsync(string idempotencyToken, CancellationToken cancellationToken = default) + public virtual async Task ExistsAsync( + string idempotencyToken, + CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()).AnyAsync(x => x.IdempotencyToken == idempotencyToken, GetCancellationToken(cancellationToken)); } @@ -161,9 +162,7 @@ public class EfCoreCommentRepository : EfCoreRepository();