Fix IO poison in handlers (UtcNow instead of a passed in date time).
This commit is contained in:
@@ -8,13 +8,13 @@ public record ApplyFeeCommand(int AccountId, decimal Amount);
|
||||
|
||||
public record FeeAppliedEvent(int AccountId, decimal Amount);
|
||||
|
||||
public record FeePair(Account Source, Account Destination);
|
||||
public record FeePair(Account Source, Account Destination, DateTimeOffset TimeStamp);
|
||||
|
||||
public static class ApplyFeeHandler
|
||||
{
|
||||
public static async Task<FeePair> LoadAsync(
|
||||
ApplyFeeCommand cmd,
|
||||
IAccountQuery query)
|
||||
IAccountQuery query, TimeProvider timeProvider)
|
||||
{
|
||||
var source = await query.FindByIdAsync(cmd.AccountId);
|
||||
var dest = await query.FindByIdAsync(99999);
|
||||
@@ -22,7 +22,8 @@ public static class ApplyFeeHandler
|
||||
{
|
||||
throw new InvalidOperationException($"Cannot process transfer. Account(s) not found.");
|
||||
}
|
||||
return new FeePair(source, dest);
|
||||
|
||||
return new FeePair(source, dest, timeProvider.GetUtcNow());
|
||||
}
|
||||
|
||||
public static (
|
||||
@@ -45,7 +46,7 @@ public static class ApplyFeeHandler
|
||||
};
|
||||
var journalEntry = BalancedJournal.Create(Guid.NewGuid(),
|
||||
$"Service Fee Applied: {cmd.Amount} to Account {cmd.AccountId}",
|
||||
DateTimeOffset.UtcNow, lines);
|
||||
pair.TimeStamp, lines);
|
||||
|
||||
var @event = new FeeAppliedEvent(cmd.AccountId, cmd.Amount);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user