Ejemplo n.º 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);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
 public static object ExtractCustomFieldValue(this InsightlyCustomFieldObject obj, string fieldName)
 {
     return(obj?.CUSTOMFIELDS?.Where(cf => cf.FIELD_NAME == fieldName)?.FirstOrDefault()?.FIELD_VALUE);
 }
Ejemplo n.º 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));
 }