| | | 1 | | using FAU.DataAccess.Repositories; |
| | | 2 | | using FAU.Entidades; |
| | | 3 | | using Serilog; |
| | | 4 | | |
| | | 5 | | namespace FAU.Logica.Services; |
| | | 6 | | |
| | | 7 | | public class AuditoriaService : IAuditoriaService |
| | | 8 | | { |
| | | 9 | | private readonly IAuditoriaRepository _auditoriaRepository; |
| | | 10 | | |
| | 2 | 11 | | public AuditoriaService(IAuditoriaRepository auditoriaRepository) |
| | | 12 | | { |
| | 2 | 13 | | _auditoriaRepository = auditoriaRepository ?? throw new ArgumentNullException(nameof(auditoriaRepository)); |
| | 2 | 14 | | } |
| | | 15 | | |
| | | 16 | | public Task<IEnumerable<BitacoraAuditoria>> GetAllAsync() |
| | | 17 | | { |
| | 1 | 18 | | return _auditoriaRepository.GetAllAsync(); |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | public void LogAuditoria(long usuarioId, int accionId, int contextoId, string host) |
| | | 22 | | { |
| | 1 | 23 | | host = host ?? "Desconocida"; |
| | 1 | 24 | | Log.Logger |
| | 1 | 25 | | .ForContext("usuario_id", usuarioId) |
| | 1 | 26 | | .ForContext("accion_id", accionId) |
| | 1 | 27 | | .ForContext("contexto_id", contextoId) |
| | 1 | 28 | | .ForContext("host", host) |
| | 1 | 29 | | .Information("Auditoria {usuario_id} {accion_id} {contexto_id} {host}", usuarioId, accionId, contextoId, hos |
| | 1 | 30 | | } |
| | | 31 | | } |