/**
 * @description       : 
 * @author            : ChangeMeIn@UserSettingsUnder.SFDoc
 * @group             : 
 * @last modified on  : 03-04-2022
 * @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
**/
global class NewAndEditRepairController extends NewAndEditBaseController {
	
    public Contact contactAWSDataId {get; set;}
    public Repair__c repair{get; set;}
    public String staticResourceContact {get; set;}
    public NewAndEditRepairController(ApexPages.StandardController controller){
        
        List<String> fieldList = new List<String>(Schema.getGlobalDescribe().get('Repair__c').getDescribe().fields.getMap().keyset());  
        // Add fields to controller. This is to avoid the SOQL error in visualforce page
        //Get Account Id from url param
    
        // System.debug('accountType = ' + );
        if(!Test.isRunningTest()){
            controller.addFields(fieldList);
        }
        Init(controller.getRecord());

        staticResourceContact = JSON.serialize(PIHelper.getPIIntegrationInfo('Contact'));

        SObject obj = controller.getRecord();
        System.debug('obj.Id = ' + obj.Id);
        repair = [Select Id, ContactD__c From Repair__c WHERE ID =:obj.Id];
        System.debug('repair.ContactD__c = ' + repair.ContactD__c);
        contactAWSDataId = [SELECT ID, AWS_Data_Id__c FROM Contact WHERE ID =:repair.ContactD__c];
        System.debug('contactAWSDataId.AWS_Data_Id__c = ' + contactAWSDataId.AWS_Data_Id__c );
    }
    @RemoteAction
    global static Response saveRepair(String RepairJson, String transId, Boolean isNew){
        return save(new Repair__c(), RepairJson, transId, isNew);
    }
}