Using the infrastructure
Going with the bank theme of the chapter, let’s create something that represents that domain. In a bank, you can open an account, deposit and withdraw money from it, and then possibly, and ultimately, close an account. All of these are very important events that happen in the lifespan of an account.
Within the root folder of the chapter code, create a file called Events.cs and make it look like the following:
using EventSourcing; namespace Chapter12; public record BankAccountOpened(string CustomerName) : IEvent; public record BankAccountClosed() : IEvent; public record DepositPerformed(decimal Amount) : IEvent; public record WithdrawalPerformed(decimal Amount) : IEvent;
The code holds all the events we want for now as record types and they all implement the IEvent interface.
Important note
In a production environment, I would recommend keeping one file per type, as that makes it easier to navigate and discover events in your...