/*
 * Author: Yanan Chen
 * Created Date: 03/02/2022
 * Purpose: Utility class for describe layouts
 * Test Class: NewAndEditLoanerApplicationDetailController 
 * History: 
 *      03/15/2022 - Yanan Chen - Initial Code.
 * 
 * */
global class NewAndEditLoanerExpressController extends NewAndEditBaseController {
    public NewAndEditLoanerExpressController (ApexPages.StandardController controller){
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Loaner_Express__c').getDescribe().fields.getMap().keyset());  
        // Add fields to controller. This is to avoid the SOQL error in visualforce page
        if(!Test.isRunningTest()){
            controller.addFields(fieldList); // contact lookup
        }
        Init(controller.getRecord());
        SObject obj = controller.getRecord();
        if(obj.Id == null){
            //初始化加载值
            obj.put('OwnerId',UserInfo.getUserId());
        }
    }

    
    @RemoteAction
    global static Response saveLoanerExpress(String sobJson, String transId, Boolean isNew){
        system.debug('JSON Payload:' + sobJson);
        return save(new Loaner_Express__c(), sobJson, transId, isNew);
    }
}