public static AccountDetailsViewModel Build(AccountModule accountModule, int accountId) { var account = accountModule.Get(accountId); return account == null ? BuildInvalidAccountViewModel() : BuildViewModel(accountModule, account); }
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); }
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 }; }
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 }; }
public static IEnumerable<AccountViewModel> Build(AccountModule accountModule) { var accounts = accountModule.GetAll(); return accounts.Select(account => BuildViewModel(accountModule, account)); }
public static IEnumerable<BankCardViewModel> Build(BankCardModule bankCardModule, AccountModule accountModule) { IEnumerable<BankCard> bankCards = bankCardModule.GetAll(); return bankCards.Select(bankCard => BuildViewModel(bankCardModule, accountModule, bankCard)); }