class FundController {

    @PostMapping("/_create")
    @ResponseStatus(HttpStatus.CREATED)
    public FundResponse create(@RequestBody FundRequest fundRequest, BindingResult errors,@RequestParam String tenantId) {

        ApplicationThreadLocals.setRequestInfo(fundRequest.getRequestInfo());
//        ApplicationThreadLocals.setTenantId();
        if (errors.hasErrors()) {
            throw new CustomBindException(errors);
        }

        ModelMapper model = new ModelMapper();
        FundResponse fundResponse = new FundResponse();
        fundResponse.setResponseInfo(getResponseInfo(fundRequest.getRequestInfo()));
        List<Fund> funds = new ArrayList<>();
        Fund fund;
        List<FundContract> fundContracts = new ArrayList<>();
        FundContract contract;

        fundRequest.getRequestInfo().setAction(Constants.ACTION_CREATE);

        for (FundContract fundContract : fundRequest.getFunds()) {
            fund = new Fund();
            model.map(fundContract, fund);
            fund.setCreatedDate(new Date());
            fund.setCreatedBy(fundRequest.getRequestInfo().getUserInfo());
            fund.setLastModifiedBy(fundRequest.getRequestInfo().getUserInfo());
            funds.add(fund);
        }

        funds = fundService.create(funds, errors, fundRequest.getRequestInfo());

        for (Fund f : funds) {
            contract = new FundContract();
            contract.setCreatedDate(new Date());
            model.map(f, contract);
            fundContracts.add(contract);
        }

        fundResponse.setFunds(fundContracts);

        return fundResponse;
    }

}