feat: add additional repository

This commit is contained in:
Stevan Freeborn
2024-08-22 16:04:41 -05:00
parent 88c8babe09
commit 0aa58c5b1a
21 changed files with 596 additions and 49 deletions
@@ -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()
{
+8
View File
@@ -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;