Browse Source

Fix wrong conflict merging from dev

pull/12087/head
enisn 5 years ago
parent
commit
a6cecec7b1
  1. 8
      modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs

8
modules/cms-kit/src/Volo.CmsKit.MongoDB/Volo/CmsKit/MongoDB/Blogs/MongoBlogPostRepository.cs

@ -111,7 +111,7 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
public async Task<List<CmsUser>> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default) public async Task<List<CmsUser>> GetAuthorsHasBlogPostsAsync(int skipCount, int maxResultCount, string sorting, string filter, CancellationToken cancellationToken = default)
{ {
var queryable = (await CreateAuthorsQueryableAsync()) var queryable = (await CreateAuthorsQueryableAsync(cancellationToken))
.Skip(skipCount) .Skip(skipCount)
.Take(maxResultCount) .Take(maxResultCount)
.OrderBy(sorting.IsNullOrEmpty() ? nameof(CmsUser.UserName) : sorting) .OrderBy(sorting.IsNullOrEmpty() ? nameof(CmsUser.UserName) : sorting)
@ -123,17 +123,17 @@ public class MongoBlogPostRepository : MongoDbRepository<CmsKitMongoDbContext, B
public async Task<int> GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default) public async Task<int> GetAuthorsHasBlogPostsCountAsync(string filter, CancellationToken cancellationToken = default)
{ {
return await AsyncExecuter.CountAsync( return await AsyncExecuter.CountAsync(
(await CreateAuthorsQueryableAsync()) (await CreateAuthorsQueryableAsync(cancellationToken))
.WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower()))); .WhereIf(!filter.IsNullOrEmpty(), x => x.UserName.Contains(filter.ToLower())));
} }
public async Task<CmsUser> GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default) public async Task<CmsUser> GetAuthorHasBlogPostAsync(Guid id, CancellationToken cancellationToken = default)
{ {
return await AsyncExecuter.FirstOrDefaultAsync(await CreateAuthorsQueryableAsync(), x => x.Id == id) return await AsyncExecuter.FirstOrDefaultAsync(await CreateAuthorsQueryableAsync(cancellationToken), x => x.Id == id)
?? throw new EntityNotFoundException(typeof(CmsUser), id); ?? throw new EntityNotFoundException(typeof(CmsUser), id);
} }
private async Task<IQueryable<CmsUser>> CreateAuthorsQueryableAsync() private async Task<IQueryable<CmsUser>> CreateAuthorsQueryableAsync(CancellationToken cancellationToken = default)
{ {
cancellationToken = GetCancellationToken(cancellationToken); cancellationToken = GetCancellationToken(cancellationToken);

Loading…
Cancel
Save