class BankBranchController {

	@PostMapping("/_update")
	@ResponseStatus(HttpStatus.CREATED)
	public BankBranchResponse update(@RequestBody BankBranchRequest bankBranchRequest, BindingResult errors,@RequestParam String tenantId) {

		if (errors.hasErrors()) {
			throw new CustomBindException(errors);
		}
		bankBranchRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE);
		ModelMapper model = new ModelMapper();
		BankBranchResponse bankBranchResponse = new BankBranchResponse();
		List<BankBranch> bankbranches = new ArrayList<>();
		bankBranchResponse.setResponseInfo(getResponseInfo(bankBranchRequest.getRequestInfo()));
		BankBranch bankBranch;
		BankBranchContract contract;
		List<BankBranchContract> bankBranchContracts = new ArrayList<>();

		for (BankBranchContract bankBranchContract : bankBranchRequest.getBankBranches()) {
			bankBranch = new BankBranch();
			model.map(bankBranchContract, bankBranch);
			bankBranch.setLastModifiedBy(bankBranchRequest.getRequestInfo().getUserInfo());
			bankBranch.setLastModifiedDate(new Date());
			bankbranches.add(bankBranch);
		}

		bankbranches = bankBranchService.update(bankbranches, errors, bankBranchRequest.getRequestInfo());

		for (BankBranch bankBranchObj : bankbranches) {
			contract = new BankBranchContract();
			model.map(bankBranchObj, contract);
			bankBranchObj.setLastModifiedDate(new Date());
			bankBranchContracts.add(contract);
		}

		bankBranchResponse.setBankBranches(bankBranchContracts);

		return bankBranchResponse;
	}

}