Skip to content

Commit b6e065a

Browse files
committed
Using AddDbContextPool for testing
1 parent 36b17e0 commit b6e065a

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

Data/UnitOfWork/UnitOfWork.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
namespace TechInventory.Data.UnitOfWork;
77

8-
public class UnitOfWork(InventoryDbContext context, ILogger<UnitOfWork> logger) : IUnitOfWork, IDisposable
8+
public class UnitOfWork : IUnitOfWork, IDisposable
99
{
1010
private readonly InventoryDbContext _context = context;
11-
private readonly ILogger<UnitOfWork> _logger = logger;
11+
12+
public UnitOfWork(InventoryDbContext context)
13+
{
14+
_context = context;
15+
}
1216

1317
private IRepository<Device> deviceRepository;
1418
private IRepository<DeviceModel> deviceModelRepository;
@@ -65,8 +69,7 @@ public async Task<Result<bool>> CommitAsync()
6569
}
6670
catch (DbUpdateException ex)
6771
{
68-
_logger.LogError(ex, "UnitOfWork::Commit falhou");
69-
return Result<bool>.Failure("Não foi possível salvar as informações (erro interno)", false);
72+
return Result<bool>.Failure($"Não foi possível salvar as informações {ex.Message}", false);
7073
}
7174
}
7275

0 commit comments

Comments
 (0)