private static BankAccountHeaderDto MapBankAccount(BL.BankAccount blBankAccount) { BankAccountHeaderDto bankAccountHeaderDto = new BankAccountHeaderDto(); bankAccountHeaderDto.Status = blBankAccount.GetStatus(); var currencyBalanceDto = new List <MoneyDto>(); foreach (var cb in blBankAccount.CurrencyBalance) { currencyBalanceDto.Add(MapMoney(cb.Value)); } bankAccountHeaderDto.Balances = currencyBalanceDto; bankAccountHeaderDto.AccountNumber = blBankAccount.GetAccountNumber().ToString(); return(bankAccountHeaderDto); }
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); }
internal State(BankAccount bankAccount) { this.bankAccount = bankAccount; }