class AccountEntityController {

    @PostMapping("/_update")
    @ResponseStatus(HttpStatus.CREATED)
    public AccountEntityResponse update(@RequestBody AccountEntityRequest accountEntityRequest, BindingResult errors,@RequestParam String tenantId) {

        if (errors.hasErrors()) {
            throw new CustomBindException(errors);
        }
        accountEntityRequest.getRequestInfo().setAction(Constants.ACTION_UPDATE);
        ModelMapper model = new ModelMapper();
        AccountEntityResponse accountEntityResponse = new AccountEntityResponse();
        List<AccountEntity> accountentities = new ArrayList<>();
        accountEntityResponse.setResponseInfo(getResponseInfo(accountEntityRequest.getRequestInfo()));
        AccountEntity accountEntity;
        AccountEntityContract contract;
        List<AccountEntityContract> accountEntityContracts = new ArrayList<>();

        for (AccountEntityContract accountEntityContract : accountEntityRequest.getAccountEntities()) {
            accountEntity = new AccountEntity();
            model.map(accountEntityContract, accountEntity);
            accountEntity.setLastModifiedBy(accountEntityRequest.getRequestInfo().getUserInfo());
            accountEntity.setLastModifiedDate(new Date());
            accountentities.add(accountEntity);
        }

        accountentities = accountEntityService.update(accountentities, errors, accountEntityRequest.getRequestInfo());

        for (AccountEntity accountEntityObj : accountentities) {
            contract = new AccountEntityContract();
            model.map(accountEntityObj, contract);
            accountEntityObj.setLastModifiedDate(new Date());
            accountEntityContracts.add(contract);
        }

        accountEntityResponse.setAccountEntities(accountEntityContracts);

        return accountEntityResponse;
    }

}