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

            return account == null
                ? BuildInvalidAccountViewModel()
                : BuildViewModel(accountService, account);
        }
        private static AccountDetailsViewModel BuildViewModel(AccountService accountService, Account account)
        {
            decimal balance = accountService.GetAccountBalance(account.Id);
            IEnumerable<Transaction> ledger = accountService.GetLedger(account.Id);
            Client client = accountService.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
            };
        }
コード例 #3
0
 public AccountController()
 {
     accountService = new AccountService(new InMemoryUnitOfWork(MvcApplication.DataStore));
 }
コード例 #4
0
        public static IEnumerable<AccountViewModel> Build(AccountService accountService)
        {
            var accounts = accountService.GetAll();

            return accounts.Select(account => BuildViewModel(accountService, account));
        }