feat(udt-011): T400.10 — inject TimeProvider into all Application handlers
All command handlers that call domain mutators now inject TimeProvider via constructor and use _timeProvider.GetUtcNow().UtcDateTime as the explicit 'now' argument. Replaces previous direct DateTime.UtcNow usage.
This commit is contained in:
@@ -11,11 +11,13 @@ public sealed class DeactivateMedioCommandHandler : ICommandHandler<DeactivateMe
|
||||
{
|
||||
private readonly IMedioRepository _repo;
|
||||
private readonly IAuditLogger _audit;
|
||||
private readonly TimeProvider _timeProvider;
|
||||
|
||||
public DeactivateMedioCommandHandler(IMedioRepository repo, IAuditLogger audit)
|
||||
public DeactivateMedioCommandHandler(IMedioRepository repo, IAuditLogger audit, TimeProvider timeProvider)
|
||||
{
|
||||
_repo = repo;
|
||||
_audit = audit;
|
||||
_timeProvider = timeProvider;
|
||||
}
|
||||
|
||||
public async Task<MedioStatusDto> Handle(DeactivateMedioCommand command)
|
||||
@@ -27,7 +29,8 @@ public sealed class DeactivateMedioCommandHandler : ICommandHandler<DeactivateMe
|
||||
if (!target.Activo)
|
||||
return new MedioStatusDto(target.Id, target.Codigo, target.Activo);
|
||||
|
||||
var updated = target.WithActivo(false);
|
||||
var now = _timeProvider.GetUtcNow().UtcDateTime;
|
||||
var updated = target.WithActivo(false, now);
|
||||
|
||||
using var tx = new TransactionScope(
|
||||
TransactionScopeOption.Required,
|
||||
|
||||
Reference in New Issue
Block a user