feat: add additional repository
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
namespace SanctionsSearch.Worker.Interfaces;
|
||||
|
||||
interface IAddressRepository : IRepository<Address>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace SanctionsSearch.Worker.Interfaces;
|
||||
|
||||
interface IAliasRepository : IRepository<Alias>
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace SanctionsSearch.Worker.Interfaces;
|
||||
|
||||
interface ICommentRepository : IRepository<Comment>
|
||||
{
|
||||
}
|
||||
@@ -3,5 +3,8 @@ namespace SanctionsSearch.Worker.Interfaces;
|
||||
interface IUnitOfWork
|
||||
{
|
||||
ISdnRepository Sdns { get; }
|
||||
IAddressRepository Addresses { get; }
|
||||
IAliasRepository Aliases { get; }
|
||||
ICommentRepository Comments { get; }
|
||||
Task SaveChangesAsync();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SanctionsSearch.Worker.Persistence;
|
||||
|
||||
class AddressRepository(
|
||||
DbContext dbContext,
|
||||
ILogger<AddressRepository> logger
|
||||
) : EfRepository<Address>(dbContext, logger), IAddressRepository
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SanctionsSearch.Worker.Persistence;
|
||||
|
||||
class AliasRepository(
|
||||
DbContext dbContext,
|
||||
ILogger<AliasRepository> logger
|
||||
) : EfRepository<Alias>(dbContext, logger), IAliasRepository
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SanctionsSearch.Worker.Persistence;
|
||||
|
||||
class CommentRepository(
|
||||
DbContext dbContext,
|
||||
ILogger<CommentRepository> logger
|
||||
) : EfRepository<Comment>(dbContext, logger), ICommentRepository
|
||||
{
|
||||
}
|
||||
@@ -4,6 +4,9 @@ class EfUnitOfWork(AppDbContext context, ILoggerFactory loggerFactory) : IUnitOf
|
||||
{
|
||||
private readonly AppDbContext _context = context;
|
||||
public ISdnRepository Sdns { get; } = new SdnRepository(context, loggerFactory.CreateLogger<SdnRepository>());
|
||||
public IAddressRepository Addresses { get; } = new AddressRepository(context, loggerFactory.CreateLogger<AddressRepository>());
|
||||
public IAliasRepository Aliases { get; } = new AliasRepository(context, loggerFactory.CreateLogger<AliasRepository>());
|
||||
public ICommentRepository Comments { get; } = new CommentRepository(context, loggerFactory.CreateLogger<CommentRepository>());
|
||||
|
||||
public async Task SaveChangesAsync()
|
||||
{
|
||||
|
||||
@@ -63,7 +63,15 @@ class Program
|
||||
builder.Services.AddScoped(rs => rs.GetRequiredService<IOptionsSnapshot<DbOptions>>().Value);
|
||||
|
||||
builder.Services.AddSingleton(TimeProvider.System);
|
||||
builder.Services.AddScoped<IOfacFileService, OfacFileService>();
|
||||
|
||||
builder.Services.AddScoped<ISdnRepository, SdnRepository>();
|
||||
builder.Services.AddScoped<IAddressRepository, AddressRepository>();
|
||||
builder.Services.AddScoped<IAliasRepository, AliasRepository>();
|
||||
builder.Services.AddScoped<ICommentRepository, CommentRepository>();
|
||||
builder.Services.AddScoped<IUnitOfWork, EfUnitOfWork>();
|
||||
builder.Services.AddDbContext<AppDbContext>();
|
||||
|
||||
builder.Services.AddHostedService<Worker>();
|
||||
|
||||
return builder;
|
||||
|
||||
Reference in New Issue
Block a user