Creado apartir del commit b888de6c92056de294456f581a56e25e734d4ab7 de develop
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using adas_core.Application.Repositories.Interfaces;
|
||||
using adas_core.Domain.Models.AppSettings;
|
||||
using adas_core.Domain.Models.MongoModels;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace adas_core.Infrastructure.Repositories;
|
||||
|
||||
public class PoCMappingRepository : MongoRepository<PoCMapping>, IPoCMappingRepository
|
||||
{
|
||||
private readonly ApiSettings _apiSettings;
|
||||
|
||||
public PoCMappingRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database) : base(database)
|
||||
{
|
||||
_apiSettings = apiSettings.Value;
|
||||
} //For testing
|
||||
|
||||
|
||||
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.Mappings;
|
||||
}
|
||||
|
||||
public async Task<PoCMapping?> FindByKey(string key)
|
||||
{
|
||||
var filterBuilder = Builders<PoCMapping>.Filter;
|
||||
var filter = filterBuilder.Eq(config => config.Id, key);
|
||||
|
||||
var result = await Collection.FindAsync(filter);
|
||||
|
||||
return await result.FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user