public void TransferMoney(AccountToTransfer accountToTransfer) { if (accountToTransfer?.AccountToTransferMoney is null) throw new ArgumentNullException(nameof(accountToTransfer)); Guard.ThrowIfNotPositiveDecimal(accountToTransfer.MoneyToTransfer, "Debe ingresar un monto válido", nameof(accountToTransfer.MoneyToTransfer)); Money = Money - accountToTransfer.MoneyToTransfer; }
//TODO: 03 - More exceptions public AccountToTransfer SearchTransfer(int transferId, DateTime date, AccountToTransfer account) { Guard.ThrowIfNull(date, "Debe ingresar una fecha", nameof(date)); Guard.ThrowIfNull(account, "Debe ingresar una Cuenta", nameof(date)); if (_transfers.All(x => x.TransferId != transferId)) throw new AccountToTransferDoesNotExistException("La cuenta a la que intenta transferir no existe"); return _transfers.First(x => x.TransferId == transferId); }
public void TransferMoney(AccountToTransfer accountToTransfer) { //TODO: 02 - Implemento transferencia. if (accountToTransfer is null) { throw new ArgumentNullException(nameof(accountToTransfer)); } if (accountToTransfer.AccountToTransferMoney is null) { throw new ArgumentNullException(nameof(accountToTransfer)); } Guard.ThrowIfNotPositiveDecimal(accountToTransfer.MoneyToTransfer, "Debe ingresar un monto válido", nameof(accountToTransfer.MoneyToTransfer)); Money = Money - accountToTransfer.MoneyToTransfer; }