private static Dictionary <Currency, Money> MapCurrencyBalance(DB.BankAccount dbBankAccount) { // map db entities to bl entities var currencyBalance = new Dictionary <Currency, Money>(); foreach (var cb in dbBankAccount.CurrencyBalance) { var currency = new BL.Currency(cb.Key); currencyBalance.Add(currency, new Money(cb.Value, currency)); } return(currencyBalance); }
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); }
public DTO.BankAccountHeaderDto GetBankAccountHeader(Guid accountId) { // 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); // map business logic entity to dto // offcourse automapper can be used BankAccountHeaderDto bankAccountHeaderDto = MapBankAccount(blBankAccount); return(bankAccountHeaderDto); }