Пример #1
0
 public static DateTime?ParseCustomFieldDate(InsightlyCustomFieldObject obj, string field)
 {
     if (obj == null || string.IsNullOrWhiteSpace(field))
     {
         return(null);
     }
     return(DateTime.TryParse(obj?.CUSTOMFIELDS?.Where(cf => cf?.FIELD_NAME == field)?.FirstOrDefault()?.FIELD_VALUE?.ToString(), out DateTime date) ? (DateTime?)date : null);
 }
Пример #2
0
        public static CustomField CreateCustomField(this InsightlyCustomFieldObject obj, string fieldName, object fieldValue)
        {
            if (obj.CUSTOMFIELDS == null)
            {
                obj.CUSTOMFIELDS = new List <CustomField>();
            }
            var customField = new CustomField()
            {
                FIELD_NAME = fieldName, FIELD_VALUE = fieldValue
            };

            obj.CUSTOMFIELDS.Add(customField);
            return(customField);
        }
Пример #3
0
 public static object ExtractCustomFieldValue(this InsightlyCustomFieldObject obj, string fieldName)
 {
     return(obj?.CUSTOMFIELDS?.Where(cf => cf.FIELD_NAME == fieldName)?.FirstOrDefault()?.FIELD_VALUE);
 }
Пример #4
0
 public static CustomField ExtractCustomField(this InsightlyCustomFieldObject obj, string fieldName, object fieldValue = null)
 {
     return(obj?.CUSTOMFIELDS?.Where(cf => cf.FIELD_NAME == fieldName)?.FirstOrDefault() ?? CreateCustomField(obj, fieldName, fieldValue));
 }