From c05eb0ecf1b7de1ad825ec86c1179fe56879fe1e Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Mon, 20 Apr 2020 13:56:50 +0300 Subject: [PATCH] added GetListByProjectId method to IDocumentRepository --- .../Volo/Docs/Admin/Documents/DocumentAdminAppService.cs | 2 +- .../Volo/Docs/Documents/IDocumentRepository.cs | 4 ++++ .../Volo/Docs/Documents/EFCoreDocumentRepository.cs | 8 ++++++++ .../Volo/Docs/Documents/MongoDocumentRepository.cs | 7 +++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs index 7e8e5dffd7..ddebc1b5d5 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/Documents/DocumentAdminAppService.cs @@ -64,7 +64,7 @@ namespace Volo.Docs.Admin.Documents 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) { diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs index 75e8a22e6d..b964705f25 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/IDocumentRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; @@ -7,6 +8,9 @@ namespace Volo.Docs.Documents { public interface IDocumentRepository : IBasicRepository { + Task> GetListByProjectId(Guid projectId, + CancellationToken cancellationToken = default); + Task FindAsync(Guid projectId, string name, string languageCode, string version, bool includeDetails = true, CancellationToken cancellationToken = default); diff --git a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs index 7698ef0b39..7a10f4c2dd 100644 --- a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; @@ -15,6 +17,12 @@ namespace Volo.Docs.Documents { } + public async Task> GetListByProjectId(Guid projectId, + CancellationToken cancellationToken = default) + { + return await DbSet.Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken: cancellationToken); + } + public async Task FindAsync(Guid projectId, string name, string languageCode, string version, bool includeDetails = true, CancellationToken cancellationToken = default) diff --git a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs index ee72171e0d..ededbe3a5a 100644 --- a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs @@ -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; @@ -15,6 +17,11 @@ namespace Volo.Docs.Documents { } + public async Task> GetListByProjectId(Guid projectId, CancellationToken cancellationToken = default) + { + return await GetMongoQueryable().Where(d => d.ProjectId == projectId).ToListAsync(cancellationToken); + } + public async Task FindAsync(Guid projectId, string name, string languageCode, string version, bool includeDetails = true, CancellationToken cancellationToken = default)