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:
2026-04-18 10:12:17 -03:00
parent 4e1d8f69ab
commit d69da5ff4c
27 changed files with 164 additions and 59 deletions

View File

@@ -11,11 +11,13 @@ public sealed class UpdateMedioCommandHandler : ICommandHandler<UpdateMedioComma
{
private readonly IMedioRepository _repo;
private readonly IAuditLogger _audit;
private readonly TimeProvider _timeProvider;
public UpdateMedioCommandHandler(IMedioRepository repo, IAuditLogger audit)
public UpdateMedioCommandHandler(IMedioRepository repo, IAuditLogger audit, TimeProvider timeProvider)
{
_repo = repo;
_audit = audit;
_timeProvider = timeProvider;
}
public async Task<MedioUpdatedDto> Handle(UpdateMedioCommand command)
@@ -23,7 +25,8 @@ public sealed class UpdateMedioCommandHandler : ICommandHandler<UpdateMedioComma
var target = await _repo.GetByIdAsync(command.Id)
?? throw new MedioNotFoundException(command.Id);
var updated = target.WithUpdatedProfile(command.Nombre, command.Tipo, command.PlataformaEmpresaId);
var now = _timeProvider.GetUtcNow().UtcDateTime;
var updated = target.WithUpdatedProfile(command.Nombre, command.Tipo, command.PlataformaEmpresaId, now);
using var tx = new TransactionScope(
TransactionScopeOption.Required,