32 lines
676 B
C#
32 lines
676 B
C#
using AccountMangement.Infrastructure.EFCore;
|
|
using Company.Domain._common;
|
|
using Microsoft.EntityFrameworkCore.Storage;
|
|
|
|
namespace CompanyManagment.EFCore._common;
|
|
|
|
public class UnitOfWork : IUnitOfWork
|
|
{
|
|
private readonly AccountContext _context;
|
|
private IDbContextTransaction _transaction;
|
|
|
|
public UnitOfWork(AccountContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public void BeginAccountContext()
|
|
{
|
|
_transaction = _context.Database.BeginTransaction();
|
|
}
|
|
|
|
public void CommitAccountContext()
|
|
{
|
|
_transaction?.Commit();
|
|
}
|
|
|
|
public void RollbackAccountContext()
|
|
{
|
|
_transaction?.Rollback();
|
|
}
|
|
}
|