public static AccountDetailsViewModel Build(AccountModule accountModule, int accountId)
        {
            var account = accountModule.Get(accountId);

            return account == null
                ? BuildInvalidAccountViewModel()
                : BuildViewModel(accountModule, account);
        }
コード例 #2
0
        public BankCardController()
        {
            unitOfWork = new InMemoryUnitOfWork(MvcApplication.DataStore);
            var accountRepository = unitOfWork.GetRepository<Account>();
            var clientModule = new ClientModule(unitOfWork.GetRepository<Client>());
            var transactionModule = new TransactionModule(unitOfWork.GetRepository<Transaction>());

            bankCardModule = new BankCardModule(unitOfWork.GetRepository<BankCard>());
            accountModule = new AccountModule(accountRepository, bankCardModule, transactionModule, clientModule);
        }
コード例 #3
0
        private static BankCardViewModel BuildViewModel(BankCardModule bankCardModule, AccountModule accountModule, BankCard bankCard)
        {
            var bankAccount = accountModule.Get(bankCard.AccountId);

            return new BankCardViewModel
            {
                Id = bankCard.Id,
                AccountNumber = bankAccount.AccountNumber,
                Status = bankCard.Disabled ? "Disabled" : "Active",
                Disabled = bankCard.Disabled
            };
        }
コード例 #4
0
        private static AccountViewModel BuildViewModel(AccountModule accountModule, Account account)
        {
            decimal balance = accountModule.GetAccountBalance(account.Id);
            Client client = accountModule.GetAccountHolder(account.Id);

            return new AccountViewModel
            {
                AccountNumber = account.AccountNumber,
                Balance = balance.ToString("C"),
                Id = account.Id,
                ClientName = client.ClientName,
                Status = account.Closed ? "Closed" : "Open",
                Closed = account.Closed
            };
        }
        private static AccountDetailsViewModel BuildViewModel(AccountModule accountModule, Account account)
        {
            decimal balance = accountModule.GetAccountBalance(account.Id);
            IEnumerable<Transaction> ledger = accountModule.GetLedger(account.Id);
            Client client = accountModule.GetAccountHolder(account.Id);

            return new AccountDetailsViewModel
            {
                AccountNumber = account.AccountNumber,
                Balance = balance.ToString("C"),
                Id = account.Id,
                ClientName = client.ClientName,
                Status = account.Closed ? "Closed" : "Open",
                Ledger = ledger
            };
        }
コード例 #6
0
        public static IEnumerable<AccountViewModel> Build(AccountModule accountModule)
        {
            var accounts = accountModule.GetAll();

            return accounts.Select(account => BuildViewModel(accountModule, account));
        }
コード例 #7
0
        public static IEnumerable<BankCardViewModel> Build(BankCardModule bankCardModule, AccountModule accountModule)
        {
            IEnumerable<BankCard> bankCards = bankCardModule.GetAll();

            return bankCards.Select(bankCard => BuildViewModel(bankCardModule, accountModule, bankCard));
        }