class BankBranchController {

	@PostMapping("/_create")
	@ResponseStatus(HttpStatus.OK)
	public BankBranchContractResponse create(@RequestBody @Valid BankBranchContractRequest bankBranchContractRequest,
			BindingResult errors) {
		bankBranchService.validate(bankBranchContractRequest, "create", errors);
		if (errors.hasErrors()) {
			throw new CustomBindException(errors);
		}
		bankBranchContractRequest.getRequestInfo().setAction("create");
		bankBranchService.fetchRelatedContracts(bankBranchContractRequest);
		bankBranchService.push(bankBranchContractRequest);
		BankBranchContractResponse bankBranchContractResponse = new BankBranchContractResponse();
		bankBranchContractResponse.setBankBranches(new ArrayList<BankBranchContract>());
		if (bankBranchContractRequest.getBankBranches() != null
				&& !bankBranchContractRequest.getBankBranches().isEmpty()) {
			for (BankBranchContract bankBranchContract : bankBranchContractRequest.getBankBranches()) {

				bankBranchContractResponse.getBankBranches().add(bankBranchContract);
			}
		} else if (bankBranchContractRequest.getBankBranch() != null) {
			bankBranchContractResponse.setBankBranch(bankBranchContractRequest.getBankBranch());
		}
		bankBranchContractResponse.setResponseInfo(getResponseInfo(bankBranchContractRequest.getRequestInfo()));

		return bankBranchContractResponse;
	}

}