Feat Varios 3
This commit is contained in:
@@ -37,4 +37,19 @@ public class AuditRepository
|
||||
ORDER BY a.CreatedAt DESC";
|
||||
return await conn.QueryAsync<AuditLog>(sql, new { UserId = userId, Limit = limit });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<AuditLog>> GetFilteredLogsAsync(DateTime from, DateTime to, int? userId = null)
|
||||
{
|
||||
using var conn = _db.CreateConnection();
|
||||
var sql = @"SELECT a.*, u.Username
|
||||
FROM AuditLogs a
|
||||
JOIN Users u ON a.UserId = u.Id
|
||||
WHERE a.CreatedAt >= @From AND a.CreatedAt <= @To";
|
||||
|
||||
if (userId.HasValue) sql += " AND a.UserId = @UserId";
|
||||
|
||||
sql += " ORDER BY a.CreatedAt DESC";
|
||||
|
||||
return await conn.QueryAsync<AuditLog>(sql, new { From = from, To = to, UserId = userId });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user