Files
demo-ddd-without-oop/csharp-fp1/Application/AccountApplicationService.cs
T
2026-04-21 23:04:56 +01:00

18 lines
455 B
C#

using CsharpFp1.Domain;
namespace CsharpFp1.Application;
public static class AccountApplicationService
{
public static void WithdrawMoney(IAccountRepository repository, Guid accountId, decimal amount)
{
var account =
repository.GetById(new AccountId(accountId))
?? throw new InvalidOperationException("Account not found.");
account.Withdraw(new Money(amount));
repository.Save(account);
}
}