protected virtual void AddHeaderFilter(HeaderFilterBaseModel filter) { HeaderFilters.Add(filter); filter.ActionFilterValueChanged = Load; filter.ActionIsUsedChanged = Load; filter.ActionIsSortedChanged = Load; filter.ActionPredicateChanged = Load; }
protected WhereExpression.IWhereOption WhereOptionFromHeaderFilter( HeaderFilterBaseModel filter) { if (filter.FilterValue != null && filter.PropertyType == typeof(string)) { var wo = new WhereExpression.WhereOptionString() { PropertyPath = filter.PropertyName, Value = (string)filter.FilterValue, Predicate = filter.Predicate }; return(wo); } else if (filter.FilterValue != null && filter.PropertyType == typeof(int)) { int number; if (int.TryParse(filter.FilterValue.ToString(), out number) == true) { var wo = new WhereExpression.WhereOptionInt() { PropertyPath = filter.PropertyName, Value = number, Predicate = filter.Predicate }; return(wo); } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } else if (filter.PropertyType == typeof(int?)) { var wo = new WhereExpression.WhereOptionNullableInt() { PropertyPath = filter.PropertyName }; if (filter.FilterValue == null) { if (filter.Predicate == WhereExpression.Equal || filter.Predicate == WhereExpression.NotEqual) { wo.Predicate = filter.Predicate; wo.Value = null; } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } else { int number; if (int.TryParse(filter.FilterValue.ToString(), out number) == true) { wo.Predicate = filter.Predicate; wo.Value = number; } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } return(wo); } else if (filter.FilterValue != null && filter.PropertyType == typeof(long)) { long number; if (long.TryParse(filter.FilterValue.ToString(), out number) == true) { var wo = new WhereExpression.WhereOptionLong() { PropertyPath = filter.PropertyName, Value = number, Predicate = filter.Predicate }; return(wo); } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } else if (filter.PropertyType == typeof(long?)) { var wo = new WhereExpression.WhereOptionNullableLong() { PropertyPath = filter.PropertyName }; if (filter.FilterValue == null) { if (filter.Predicate == WhereExpression.Equal || filter.Predicate == WhereExpression.NotEqual) { wo.Predicate = filter.Predicate; wo.Value = null; } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } else { long number; if (long.TryParse(filter.FilterValue.ToString(), out number) == true) { wo.Predicate = filter.Predicate; wo.Value = number; } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } return(wo); } else if (filter.FilterValue != null && filter.PropertyType == typeof(bool)) { if (filter.Predicate == WhereExpression.Equal || filter.Predicate == WhereExpression.NotEqual) { var wo = new WhereExpression.WhereOptionBool() { Predicate = filter.Predicate, PropertyPath = filter.PropertyName, Value = (bool)filter.FilterValue }; return(wo); } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } else if (filter.PropertyType == typeof(bool?)) { if (filter.Predicate == WhereExpression.Equal || filter.Predicate == WhereExpression.NotEqual) { var wo = new WhereExpression.WhereOptionNullableBool() { Predicate = filter.Predicate, PropertyPath = filter.PropertyName, Value = (bool?)filter.FilterValue }; return(wo); } else { throw new ArgumentException(string.Format("filter: {0} not valid", filter.Name)); } } else if (filter.FilterValue != null && filter.PropertyType == typeof(DateTime)) { var wo = new WhereExpression.WhereOptionDate() { Predicate = filter.Predicate, PropertyPath = filter.PropertyName, Value = (DateTime)filter.FilterValue }; return(wo); } else if (filter.PropertyType == typeof(DateTime?)) { var wo = new WhereExpression.WhereOptionNullableDate() { Predicate = filter.Predicate, PropertyPath = filter.PropertyName, Value = (DateTime?)filter.FilterValue }; return(wo); } else if (filter.FilterValue != null && filter.PropertyType == typeof(TimeSpan)) { var wo = new WhereExpression.WhereOptionTime() { Predicate = filter.Predicate, PropertyPath = filter.PropertyName, Value = (TimeSpan)filter.FilterValue }; return(wo); } else if (filter.PropertyType == typeof(TimeSpan?)) { var wo = new WhereExpression.WhereOptionNullableTime() { Predicate = filter.Predicate, PropertyPath = filter.PropertyName, Value = (TimeSpan?)filter.FilterValue }; return(wo); } return(null); }