Esempio n. 1
0
        private ZCRMBulkWriteFieldMapping SetZCRMBulkWriteFieldMappingObject(JObject fieldMappingJSON)
        {
            ZCRMBulkWriteFieldMapping fieldMappingObj = ZCRMBulkWriteFieldMapping.GetInstance();

            if (fieldMappingJSON.ContainsKey("api_name") && fieldMappingJSON["api_name"].Type != JTokenType.Null)
            {
                fieldMappingObj.FieldAPIName = (string)fieldMappingJSON["api_name"];
            }
            if (fieldMappingJSON.ContainsKey("index") && fieldMappingJSON["index"].Type != JTokenType.Null)
            {
                fieldMappingObj.Index = Convert.ToInt32(fieldMappingJSON["index"]);
            }
            if (fieldMappingJSON.ContainsKey("find_by") && fieldMappingJSON["find_by"].Type != JTokenType.Null)
            {
                fieldMappingObj.FindBy = (string)fieldMappingJSON["find_by"];
            }
            if (fieldMappingJSON.ContainsKey("format") && fieldMappingJSON["format"].Type != JTokenType.Null)
            {
                fieldMappingObj.Format = (string)fieldMappingJSON["format"];
            }
            if (fieldMappingJSON.ContainsKey("default_value") && fieldMappingJSON["default_value"].Type != JTokenType.Null)
            {
                JObject defaultValueJSON = (JObject)fieldMappingJSON["default_value"];
                foreach (KeyValuePair <string, JToken> defaultValue in defaultValueJSON)
                {
                    fieldMappingObj.SetDefaultValue(defaultValue.Key, (object)defaultValue.Value);
                }
            }
            return(fieldMappingObj);
        }
Esempio n. 2
0
        private JObject GetZCRMBulkWriteFieldMappingJSONObject(ZCRMBulkWriteFieldMapping fieldMappingObj)
        {
            JObject fieldMappingJSON = new JObject();

            if (fieldMappingObj.FieldAPIName != null)
            {
                fieldMappingJSON.Add("api_name", fieldMappingObj.FieldAPIName);
            }
            if (fieldMappingObj.Index != null)
            {
                fieldMappingJSON.Add("index", fieldMappingObj.Index);
            }
            if (fieldMappingObj.DefaultValue != null && fieldMappingObj.DefaultValue.Count > 0)
            {
                fieldMappingJSON.Add("default_value", this.GetDefaultValueAsJSON(fieldMappingObj.DefaultValue));
            }
            if (fieldMappingObj.FindBy != null)
            {
                fieldMappingJSON.Add("find_by", fieldMappingObj.FindBy);
            }
            if (fieldMappingObj.Format != null)
            {
                fieldMappingJSON.Add("format", fieldMappingObj.Format);
            }
            return(fieldMappingJSON);
        }