Added a transfer funds handler using a-frame and wolverine.

This commit is contained in:
2026-07-14 16:57:03 +02:00
parent 9de9777926
commit 0de38ef2df
7 changed files with 105 additions and 25 deletions
@@ -0,0 +1,43 @@
namespace FinancialApi.Application;
public record Account(int Id, decimal Balance)
{
public Account ApplyFee(decimal amount)
{
if (amount <= 0)
{
throw new ArgumentException("Fee must be positive.");
}
if (Balance - amount < 0)
{
throw new InvalidOperationException("Insufficient funds.");
}
return this with { Balance = Balance - amount };
}
public Account Debit(decimal amount)
{
if (amount <= 0)
{
throw new ArgumentException("Debit amount must be positive.");
}
if (Balance - amount < 0)
{
throw new InvalidOperationException("Insufficient funds.");
}
return this with { Balance = Balance - amount };
}
public Account Credit(decimal amount)
{
if (amount <= 0)
{
throw new ArgumentException("Credit amount must be positive.");
}
return this with { Balance = Balance + amount };
}
}
@@ -1,16 +0,0 @@
namespace FinancialApi.Application;
public record Account(int Id, decimal Balance)
{
public Account ApplyFee(decimal amount)
{
if (amount <= 0)
throw new ArgumentException("Fee must be positive.");
if (Balance - amount < 0)
throw new InvalidOperationException("Insufficient funds.");
// Returns a brand new record with the updated balance
return this with { Balance = Balance - amount };
}
}