class AccountDetailTypeController {

	@PostMapping("/_update")
	@ResponseStatus(HttpStatus.CREATED)
	public AccountDetailTypeResponse update(@RequestBody AccountDetailTypeRequest accountDetailTypeRequest,
			BindingResult errors,@RequestParam String tenantId) {

		if (errors.hasErrors()) {
			throw new CustomBindException(errors);
		}
		accountDetailTypeRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE);
		ModelMapper model = new ModelMapper();
		AccountDetailTypeResponse accountDetailTypeResponse = new AccountDetailTypeResponse();
		List<AccountDetailType> accountdetailtypes = new ArrayList<>();
		accountDetailTypeResponse.setResponseInfo(getResponseInfo(accountDetailTypeRequest.getRequestInfo()));
		AccountDetailType accountDetailType;
		AccountDetailTypeContract contract;
		List<AccountDetailTypeContract> accountDetailTypeContracts = new ArrayList<>();

		for (AccountDetailTypeContract accountDetailTypeContract : accountDetailTypeRequest.getAccountDetailTypes()) {
			accountDetailType = new AccountDetailType();
			model.map(accountDetailTypeContract, accountDetailType);
			accountDetailType.setLastModifiedBy(accountDetailTypeRequest.getRequestInfo().getUserInfo());
			accountDetailType.setLastModifiedDate(new Date());
			accountdetailtypes.add(accountDetailType);
		}

		accountdetailtypes = accountDetailTypeService.update(accountdetailtypes, errors,
				accountDetailTypeRequest.getRequestInfo());

		for (AccountDetailType accountDetailTypeObj : accountdetailtypes) {
			contract = new AccountDetailTypeContract();
			model.map(accountDetailTypeObj, contract);
			accountDetailTypeObj.setLastModifiedDate(new Date());
			accountDetailTypeContracts.add(contract);
		}

		accountDetailTypeResponse.setAccountDetailTypes(accountDetailTypeContracts);

		return accountDetailTypeResponse;
	}

}