feat: implement building address table from csv

This commit is contained in:
Stevan Freeborn
2024-08-24 16:06:44 -05:00
parent 86527efad9
commit 0b9a83619d
4 changed files with 154 additions and 12 deletions
@@ -3,6 +3,7 @@ namespace SanctionsSearch.Worker.Persistence;
class EfUnitOfWork(DbContext context, ILoggerFactory loggerFactory) : IUnitOfWork, IAsyncDisposable
{
private readonly DbContext _context = context;
private readonly ILogger<EfUnitOfWork> _logger = loggerFactory.CreateLogger<EfUnitOfWork>();
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>());
@@ -10,11 +11,25 @@ class EfUnitOfWork(DbContext context, ILoggerFactory loggerFactory) : IUnitOfWor
public async Task SaveChangesAsync()
{
await _context.SaveChangesAsync();
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateException ex)
{
_logger.LogError(ex, "Failed to save changes to the database.");
}
}
public async ValueTask DisposeAsync()
{
await _context.DisposeAsync();
try
{
await _context.DisposeAsync();
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to dispose of the database context.");
}
}
}