Fix logic for counting blog posts

This commit is contained in:
Robert Marshall 2023-02-01 21:55:05 +00:00
parent 93cfc85b4c
commit 0460f8c945

View file

@ -35,7 +35,8 @@ namespace Robware.Data {
public async Task<IEnumerable<BlogPost>> GetAllPostsAsync() => MapStateToPost((await _collection.FindAsync(post => !post.Deleted)).ToEnumerable());
private async Task<int> GetCountAsync(bool includeAll) => (int)await _collection.CountDocumentsAsync(post => includeAll || (!post.Deleted && string.IsNullOrEmpty(post.Content)));
private async Task<int> GetCountAsync(bool includeAll) =>
(int)await _collection.CountDocumentsAsync(post => includeAll || !(post.Deleted || string.IsNullOrEmpty(post.Content)));
public async Task<int> GetCountAsync() => await GetCountAsync(false);