Distribution_GL Initialization

This commit is contained in:
2026-10-20 13:07:07 +05:30
commit 3f16e0cb44
194 changed files with 35659 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Storage;
namespace General_Ledger_Service.Infra.UoW
{
public class EFUnitOfWork : IUnitOfWork
{
private readonly AppDBContext _dbContext;
private IDbContextTransaction? _transaction;
public EFUnitOfWork(AppDBContext dbContext)
{
_dbContext = dbContext;
}
public async Task BeginAsync(CancellationToken ct = default)
{
if (_transaction == null)
_transaction = await _dbContext.Database.BeginTransactionAsync(ct);
}
public async Task SaveChangesAsync(CancellationToken ct = default)
{
await _dbContext.SaveChangesAsync(ct);
}
public async Task CommitAsync(CancellationToken ct = default)
{
await _dbContext.SaveChangesAsync(ct);
if (_transaction != null)
{
await _transaction.CommitAsync(ct);
await _transaction.DisposeAsync();
_transaction = null;
}
}
public async Task RollbackAsync(CancellationToken ct = default)
{
if (_transaction != null)
{
await _transaction.RollbackAsync(ct);
await _transaction.DisposeAsync();
_transaction = null;
}
}
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace General_Ledger_Service.Infra.UoW
{
public interface IUnitOfWork
{
Task BeginAsync(CancellationToken ct = default);
Task CommitAsync(CancellationToken ct = default);
Task RollbackAsync(CancellationToken ct = default);
Task SaveChangesAsync(CancellationToken ct = default);
}
}