Browse Source

Merge branch 'master' of github.com:Squidex/squidex

pull/596/head
Sebastian 5 years ago
parent
commit
a475372125
  1. 20
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository.cs

20
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Assets/MongoAssetRepository.cs

@ -129,27 +129,27 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Assets
} }
} }
public async Task<IAssetEntity?> FindAssetBySlugAsync(DomainId appId, string slug) public async Task<IReadOnlyList<IAssetEntity>> QueryByHashAsync(DomainId appId, string hash)
{ {
using (Profiler.TraceMethod<MongoAssetRepository>()) using (Profiler.TraceMethod<MongoAssetRepository>())
{ {
var assetEntity = var assetEntities =
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.Slug == slug) await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.FileHash == hash)
.FirstOrDefaultAsync(); .ToListAsync();
return assetEntity; return assetEntities.OfType<IAssetEntity>().ToList();
} }
} }
public async Task<IReadOnlyList<IAssetEntity>> QueryByHashAsync(DomainId appId, string hash) public async Task<IAssetEntity?> FindAssetBySlugAsync(DomainId appId, string slug)
{ {
using (Profiler.TraceMethod<MongoAssetRepository>()) using (Profiler.TraceMethod<MongoAssetRepository>())
{ {
var assetEntities = var assetEntity =
await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.FileHash == hash) await Collection.Find(x => x.IndexedAppId == appId && !x.IsDeleted && x.Slug == slug)
.ToListAsync(); .FirstOrDefaultAsync();
return assetEntities.OfType<IAssetEntity>().ToList(); return assetEntity;
} }
} }

Loading…
Cancel
Save