public async Task <ActionResult <BankAccountModel> > Get(int customerId, int Id) { try { var result = await _repository.GetBankAccountAsync(customerId, Id); if (result == null) { return(NotFound()); } return(_mapper.Map <BankAccountModel>(result)); } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } }
public async Task <Credit> ProcessCreditWithBankAsync(Credit credit) { var invoice = await _invoiceRepository.GetInvoiceAsync(credit.InvoiceId); var customer = await _customerRepository.GetCustomerAsync(invoice.CustomerId); var bankAccount = await _bankAccountRepository.GetBankAccountAsync(customer.Id, null); credit.CustomerName = $"{customer.Title} {customer.FirstName} {customer.MiddleName} {customer.LastName}"; credit.AccountNo = bankAccount.AccountNo; credit.SortCode = bankAccount.SortCode; credit.HasCreditAgreement = customer.CreditAgreement; SendCreditToBack(credit); return(credit); }