Added Event Tracking!

This commit is contained in:
2026-07-16 16:36:46 +02:00
parent 50e74a0034
commit ee1e64c944
6 changed files with 81 additions and 1 deletions
@@ -11,6 +11,9 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Extensions.Logging.Abstractions">
<HintPath>..\..\..\..\..\..\.nuget\packages\microsoft.extensions.logging.abstractions\10.0.9\lib\net10.0\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Wolverine">
<HintPath>..\..\..\..\..\..\.nuget\packages\wolverinefx\6.18.0\lib\net10.0\Wolverine.dll</HintPath>
</Reference>
@@ -0,0 +1,42 @@
using Microsoft.Extensions.Logging;
namespace FinancialApi.Application;
public static class FinancialEventHandler
{
public static void Handle(
FeeAppliedEvent @event,
IEventTracker store,
ILogger logger)
{
var message = $"FeeApplied: ${@event.Amount} moved from Account {@event.AccountId} to Account 99999.";
logger.LogInformation("BACKGROUND EVENT FIRED: {Message}", message);
// Save to our UI bucket
store.Add(message);
}
public static void Handle(
FundsTransferredEvent @event,
IEventTracker store,
ILogger logger)
{
var message = $"FundsTransferred: ${@event.Amount} moved from Account {@event.SourceAccountId} to Account {@event.DestinationAccountId}.";
logger.LogInformation("BACKGROUND EVENT FIRED: {Message}", message);
// Save to our UI bucket
store.Add(message);
}
public static void Handle(
JournalReversedEvent @event,
IEventTracker store,
ILogger logger)
{
var message = $"JournalReversed: Original Entry {@event.OriginalJournalId} was reversed by Entry {@event.ReversalJournalId}.";
logger.LogInformation("BACKGROUND EVENT FIRED: {Message}", message);
store.Add(message);
}
}
@@ -0,0 +1,6 @@
namespace FinancialApi.Application;
public interface IEventTracker
{
void Add(string eventMessage);
}