Reformat all code as per my preferred formatting.
This commit is contained in:
+14
-18
@@ -11,8 +11,11 @@ namespace FinancialApi.Application.Handlers;
|
||||
|
||||
public static class TransferFundsHandler
|
||||
{
|
||||
public static async Task<TransferContext?> LoadAsync(TransferFundsCommand cmd, IAccountQuery query,
|
||||
TimeProvider timeProvider)
|
||||
public static async Task<TransferContext?> LoadAsync(
|
||||
TransferFundsCommand cmd,
|
||||
IAccountQuery query,
|
||||
TimeProvider timeProvider
|
||||
)
|
||||
{
|
||||
var source = await query.FindByIdAsync(cmd.SourceAccountId);
|
||||
var dest = await query.FindByIdAsync(cmd.DestinationAccountId);
|
||||
@@ -22,12 +25,8 @@ public static class TransferFundsHandler
|
||||
return new TransferContext(source, dest, timeProvider.GetUtcNow());
|
||||
}
|
||||
|
||||
public static (
|
||||
IStorageAction<Account> SourceWrite,
|
||||
IStorageAction<Account> DestWrite,
|
||||
IStorageAction<JournalEntry> JournalWrite,
|
||||
FundsTransferredEvent Event
|
||||
) Handle(TransferFundsCommand cmd, TransferContext context)
|
||||
public static ( IStorageAction<Account> SourceWrite, IStorageAction<Account> DestWrite, IStorageAction<JournalEntry>
|
||||
JournalWrite, FundsTransferredEvent Event ) Handle(TransferFundsCommand cmd, TransferContext context)
|
||||
{
|
||||
var updatedSource = context.Source.Debit(cmd.Amount);
|
||||
var updatedDest = context.Destination.Credit(cmd.Amount);
|
||||
@@ -38,18 +37,15 @@ public static class TransferFundsHandler
|
||||
new(context.Destination.Id, cmd.Amount, EntryType.Credit)
|
||||
};
|
||||
|
||||
var journalEntry =
|
||||
BalancedJournal.Create(Guid.NewGuid(),
|
||||
$"Transfer: {cmd.Amount} from {cmd.SourceAccountId} to {cmd.DestinationAccountId}",
|
||||
context.TimeStamp, lines);
|
||||
var journalEntry = BalancedJournal.Create(
|
||||
Guid.NewGuid(),
|
||||
$"Transfer: {cmd.Amount} from {cmd.SourceAccountId} to {cmd.DestinationAccountId}",
|
||||
context.TimeStamp,
|
||||
lines
|
||||
);
|
||||
|
||||
var @event = new FundsTransferredEvent(cmd.SourceAccountId, cmd.DestinationAccountId, cmd.Amount);
|
||||
|
||||
return (
|
||||
Storage.Update(updatedSource),
|
||||
Storage.Update(updatedDest),
|
||||
Storage.Insert(journalEntry.Entry),
|
||||
@event
|
||||
);
|
||||
return (Storage.Update(updatedSource), Storage.Update(updatedDest), Storage.Insert(journalEntry.Entry), @event);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user