Skip to content

Commit

Permalink
added GetListByProjectId method to IDocumentRepository
Browse files Browse the repository at this point in the history
  • Loading branch information
yekalkan committed Apr 20, 2020
1 parent 669e0e9 commit c05eb0e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task ClearCacheAsync(ClearCacheInput input)
await _languageCache.RemoveAsync(languageCacheKey, true);
await _versionCache.RemoveAsync(versionCacheKey, true);

var documents = await _documentRepository.GetListAsync();
var documents = await _documentRepository.GetListByProjectId(project.Id);

foreach (var languageCode in languageConfig.Languages)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
Expand All @@ -7,6 +8,9 @@ namespace Volo.Docs.Documents
{
public interface IDocumentRepository : IBasicRepository<Document>
{
Task<List<Document>> GetListByProjectId(Guid projectId,
CancellationToken cancellationToken = default);

Task<Document> FindAsync(Guid projectId, string name, string languageCode, string version,
bool includeDetails = true,
CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
Expand All @@ -15,6 +17,12 @@ public EFCoreDocumentRepository(IDbContextProvider<IDocsDbContext> dbContextProv
{
}

public async Task<List<Document>> GetListByProjectId(Guid projectId,
CancellationToken cancellationToken = default)
{
return await DbSet.Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken: cancellationToken);
}

public async Task<Document> FindAsync(Guid projectId, string name, string languageCode, string version,
bool includeDetails = true,
CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.MongoDB;
Expand All @@ -15,6 +17,11 @@ public MongoDocumentRepository(IMongoDbContextProvider<IDocsMongoDbContext> dbCo
{
}

public async Task<List<Document>> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken);
}

public async Task<Document> FindAsync(Guid projectId, string name, string languageCode, string version,
bool includeDetails = true,
CancellationToken cancellationToken = default)
Expand Down

0 comments on commit c05eb0e

Please sign in to comment.