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
            };
        }
 public AccountController()
 {
     accountService = new AccountService(new InMemoryUnitOfWork(MvcApplication.DataStore));
 }
        public static IEnumerable<AccountViewModel> Build(AccountService accountService)
        {
            var accounts = accountService.GetAll();

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