public void Withdraw() { var bankAccountController = new BankAccountController(); MoneyParams amount = new MoneyParams("PLN", 1000m); var bankAccountHeader = bankAccountController.Withdraw(Guid.Parse("4939209E-8CAA-4722-AC0D-31A1B15462DD"), amount); Assert.AreEqual(bankAccountHeader.Balances.First().Amount, 0m); Assert.AreEqual(bankAccountHeader.Balances.First().CurrencyISOCode, "PLN"); }
public BankAccountHeaderDto Withdraw(Guid accountId, MoneyParams moneyParams) { // get data from db DB.BankAccount dbBankAccount = this.AssertBankAccount(accountId); // map db entities to bl entities // offcourse automapper can be used Dictionary <Currency, Money> blCurrencyBalance = MapCurrencyBalance(dbBankAccount); IState blState = MapState(dbBankAccount.State); // apply business logic BL.BankAccount blBankAccount = LoadBankAccount(dbBankAccount.Id, dbBankAccount.UserId, blCurrencyBalance, blState); Money amount = new Money(moneyParams.Amount, new Currency(moneyParams.CurrencyISOCode)); var money = blBankAccount.Withdraw(amount); BankAccountHeaderDto bankAccountHeaderDto = MapBankAccount(blBankAccount); return(bankAccountHeaderDto); }