Created
May 31, 2017 10:30
-
-
Save zeromodule/028804d384929ac31136ece954fb8314 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void WithdrawMoney(decimal amount) | |
{ | |
Atm atm = _repository.Get(); | |
_atmService.WithdrawMoney(atm, amount); | |
_repository.Save(_atm); | |
} | |
public sealed class AtmService // Domain service | |
{ | |
public void WithdrawMoney(Atm atm, decimal amount) | |
{ | |
if (!atm.CanDispenseMoney(amount)) | |
return; | |
decimal amountWithCommission = atm.CalculateAmountWithCommission(amount); | |
Result result = _paymentGateway.ChargePayment(amountWithCommission); | |
if (result.IsFailure) | |
return; | |
atm.DispenseMoney(amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment