class AccountDetailKeyController {

	@PostMapping("/_update")
	@ResponseStatus(HttpStatus.CREATED)
	public AccountDetailKeyResponse update(@RequestBody AccountDetailKeyRequest accountDetailKeyRequest,
			BindingResult errors,@RequestParam String tenantId) {

		if (errors.hasErrors()) {
			throw new CustomBindException(errors);
		}
		accountDetailKeyRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE);
		ModelMapper model = new ModelMapper();
		AccountDetailKeyResponse accountDetailKeyResponse = new AccountDetailKeyResponse();
		List<AccountDetailKey> accountdetailkeys = new ArrayList<>();
		accountDetailKeyResponse.setResponseInfo(getResponseInfo(accountDetailKeyRequest.getRequestInfo()));
		AccountDetailKey accountDetailKey;
		AccountDetailKeyContract contract;
		List<AccountDetailKeyContract> accountDetailKeyContracts = new ArrayList<>();

		for (AccountDetailKeyContract accountDetailKeyContract : accountDetailKeyRequest.getAccountDetailKeys()) {
			accountDetailKey = new AccountDetailKey();
			model.map(accountDetailKeyContract, accountDetailKey);
			accountDetailKey.setLastModifiedBy(accountDetailKeyRequest.getRequestInfo().getUserInfo());
			accountDetailKey.setLastModifiedDate(new Date());
			accountdetailkeys.add(accountDetailKey);
		}

		accountdetailkeys = accountDetailKeyService.update(accountdetailkeys, errors,
				accountDetailKeyRequest.getRequestInfo());

		for (AccountDetailKey accountDetailKeyObj : accountdetailkeys) {
			contract = new AccountDetailKeyContract();
			model.map(accountDetailKeyObj, contract);
			accountDetailKeyObj.setLastModifiedDate(new Date());
			accountDetailKeyContracts.add(contract);
		}

		accountDetailKeyResponse.setAccountDetailKeys(accountDetailKeyContracts);

		return accountDetailKeyResponse;
	}

}