public FindBankAccountResponse GetBankAccountBy(Guid Id) { FindBankAccountResponse bankAccountResponse = new FindBankAccountResponse(); BankAccount acc = _bankRepository.FindBy(Id); BankAccountView bankAccountView = ViewMapper.CreateBankAccountViewFrom(acc); foreach (Transaction tran in acc.GetTransactions()) { bankAccountView.Transactions.Add( ViewMapper.CreateTransactionViewFrom(tran)); } bankAccountResponse.BankAccount = bankAccountView; return(bankAccountResponse); }
public FindBankAccountResponse GetBankAccountBy(Guid id) { // new FindBankAccountResponse object FindBankAccountResponse bankAccountResponse = new FindBankAccountResponse(); // return account from repository BankAccount acc = _bankRepository.Find(id); // that account convert into BankAccountView BankAccountView bankAccountView = ViewMapper.CreateBankAccountViewFrom(acc); // iterate through account GetTransactions() foreach (Transaction tran in acc.GetTransactions()) { // add transactions to BankAccountView bankAccountView.Transactions.Add( ViewMapper.CreateTransactionViewFrom(tran)); } // bankAccoiuntResponse.BankAccount = bankAccountView bankAccountResponse.BankAccount = bankAccountView; return(bankAccountResponse); }