コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 internal State(BankAccount bankAccount)
 {
     this.bankAccount = bankAccount;
 }