class BankAccountController {

	@PostMapping("/_update")
	@ResponseStatus(HttpStatus.CREATED)
	public BankAccountResponse update(@RequestBody BankAccountRequest bankAccountRequest, BindingResult errors,@RequestParam String tenantId) {

		if (errors.hasErrors()) {
			throw new CustomBindException(errors);
		}
		bankAccountRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE);
		ModelMapper model = new ModelMapper();
		BankAccountResponse bankAccountResponse = new BankAccountResponse();
		List<BankAccount> bankaccounts = new ArrayList<>();
		bankAccountResponse.setResponseInfo(getResponseInfo(bankAccountRequest.getRequestInfo()));
		BankAccount bankAccount;
		BankAccountContract contract;
		List<BankAccountContract> bankAccountContracts = new ArrayList<>();

		for (BankAccountContract bankAccountContract : bankAccountRequest.getBankAccounts()) {
			bankAccount = new BankAccount();
			model.map(bankAccountContract, bankAccount);
			bankAccount.setLastModifiedBy(bankAccountRequest.getRequestInfo().getUserInfo());
			bankAccount.setLastModifiedDate(new Date());
			bankaccounts.add(bankAccount);
		}

		bankaccounts = bankAccountService.update(bankaccounts, errors, bankAccountRequest.getRequestInfo());

		for (BankAccount bankAccountObj : bankaccounts) {
			contract = new BankAccountContract();
			model.map(bankAccountObj, contract);
			bankAccountObj.setLastModifiedDate(new Date());
			bankAccountContracts.add(contract);
		}

		bankAccountResponse.setBankAccounts(bankAccountContracts);

		return bankAccountResponse;
	}

}