Exemplo n.º 1
0
        internal static int GetFieldIdByName(string fieldName, FormResponse form)
        {
            if (string.IsNullOrEmpty(fieldName))
            {
                throw new ArgumentException("Field name can not be empty");
            }

            List <int> fields = null;

            if (form.Fields != null)
            {
                fields = form.Fields.Where(f => !string.IsNullOrEmpty(f.Name) && f.Name.ToUpper().Equals(fieldName.ToUpper()) && f.Id.HasValue).Select(f => f.Id.Value).ToList();

                if (fields.Count > 1)
                {
                    throw new ArgumentException("Field name is not unique on the form.");
                }

                if (fields.Count == 0)
                {
                    fields = ValidateFlatFieldsCount(fieldName, form);
                }
            }
            else
            {
                fields = ValidateFlatFieldsCount(fieldName, form);
            }

            return(fields.First());
        }
Exemplo n.º 2
0
        private static List <int> ValidateFlatFieldsCount(string fieldName, FormResponse form)
        {
            if (form.FlatFields == null)
            {
                throw new ArgumentException($"There is no fields on the form {form.Id}");
            }

            var fields = form.FlatFields.Where(f => !string.IsNullOrEmpty(f.Name) && f.Name.ToUpper().Equals(fieldName.ToUpper()) && f.Id.HasValue).Select(f => f.Id.Value).ToList();

            if (fields.Count > 1)
            {
                throw new ArgumentException("Field name is not unique on the form.");
            }

            if (fields.Count == 0)
            {
                throw new ArgumentException("Field with specified name not found on the form.");
            }
            return(fields);
        }
 public IsInFilter(string fieldName, IEnumerable <object> values, FormResponse form)
     : base(OperatorId.IsIn, values.ToArray())
 {
     FieldId = GetFieldIdByName(fieldName, form);
 }
 public RangeFilter(string fieldName, object fromValue, object toValue, FormResponse form)
     : this(GetFieldIdByName(fieldName, form), fromValue, toValue)
 {
 }