using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace HLWebOKBQueryPlugin.ViewModels { public class ComparisonsHelper { private static String ORDINAL_COMPARISONS_LESS = "<"; private static String ORDINAL_COMPARISONS_LESS_OR_EQUAL = "<="; private static String ORDINAL_COMPARISONS_EQUAL = "="; private static String ORDINAL_COMPARISONS_GREATER_OR_EQUAL = ">="; private static String ORDINAL_COMPARISONS_GREATER = ">"; private static String ORDINAL_COMPARISONS_NOT_EQUAL = "<>"; private static String STRING_COMPARISONS_EQUAL = "="; private static String STRING_COMPARISONS_NOT_EQUAL = "<>"; private static String STRING_COMPARISONS_CONTAINS = "contains"; private static String STRING_COMPARISONS_NOT_CONTAINS = "not contains"; private static String STRING_COMPARISONS_LIKE = "like"; private static String STRING_COMPARISONS_NOT_LIKE = "not like"; private static String BOOL_COMPARISONS_EQUAL = "="; private static String BOOL_COMPARISONS_NOT_EQUAL = "<>"; public static List boolComparisons = new List() { new ComparisonItem((int)OKBQueryService.EqualityComparison.Equal, BOOL_COMPARISONS_EQUAL), new ComparisonItem((int)OKBQueryService.EqualityComparison.NotEqual, BOOL_COMPARISONS_NOT_EQUAL) }; public static List ordinalComparisons = new List() { new ComparisonItem((int)OKBQueryService.OrdinalComparison.Less, ORDINAL_COMPARISONS_LESS), new ComparisonItem((int)OKBQueryService.OrdinalComparison.LessOrEqual, ORDINAL_COMPARISONS_LESS_OR_EQUAL), new ComparisonItem((int)OKBQueryService.OrdinalComparison.Equal, ORDINAL_COMPARISONS_EQUAL), new ComparisonItem((int)OKBQueryService.OrdinalComparison.GreaterOrEqual, ORDINAL_COMPARISONS_GREATER_OR_EQUAL), new ComparisonItem((int)OKBQueryService.OrdinalComparison.Greater, ORDINAL_COMPARISONS_GREATER), new ComparisonItem((int)OKBQueryService.OrdinalComparison.NotEqual, ORDINAL_COMPARISONS_NOT_EQUAL) }; public static List stringComparisons = new List() { new ComparisonItem((int)OKBQueryService.StringComparison.Equal, STRING_COMPARISONS_EQUAL), new ComparisonItem((int)OKBQueryService.StringComparison.NotEqual, STRING_COMPARISONS_NOT_EQUAL), new ComparisonItem((int)OKBQueryService.StringComparison.Contains, STRING_COMPARISONS_CONTAINS), new ComparisonItem((int)OKBQueryService.StringComparison.NotContains, STRING_COMPARISONS_NOT_CONTAINS), new ComparisonItem((int)OKBQueryService.StringComparison.Like, STRING_COMPARISONS_LIKE), new ComparisonItem((int)OKBQueryService.StringComparison.NotLike, STRING_COMPARISONS_NOT_LIKE) }; //public static String GetValueForStringComparision(OKBQueryService.StringComparison comparisionValue) //{ // switch (comparisionValue) // { // case OKBQueryService.StringComparison.Equal: // return STRING_COMPARISONS_EQUAL; // case OKBQueryService.StringComparison.Contains: // return STRING_COMPARISONS_CONTAINS; // case OKBQueryService.StringComparison.Like: // return STRING_COMPARISONS_LIKE; // case OKBQueryService.StringComparison.NotContains: // return STRING_COMPARISONS_NOT_CONTAINS; // case OKBQueryService.StringComparison.NotEqual: // return STRING_COMPARISONS_NOT_EQUAL; // case OKBQueryService.StringComparison.NotLike: // return STRING_COMPARISONS_NOT_LIKE; // default: // return STRING_COMPARISONS_EQUAL; //TODO // } //} public static OKBQueryService.StringComparison GetStringComparisonForValue(string comparisonValue) { int v = Int32.Parse(comparisonValue); switch (v) { case (int)OKBQueryService.StringComparison.Equal: return OKBQueryService.StringComparison.Equal; case (int)OKBQueryService.StringComparison.Contains: return OKBQueryService.StringComparison.Contains; case (int)OKBQueryService.StringComparison.Like: return OKBQueryService.StringComparison.Like; case (int)OKBQueryService.StringComparison.NotContains: return OKBQueryService.StringComparison.NotContains; case (int)OKBQueryService.StringComparison.NotEqual: return OKBQueryService.StringComparison.NotEqual; case (int)OKBQueryService.StringComparison.NotLike: return OKBQueryService.StringComparison.NotLike; default: return OKBQueryService.StringComparison.Equal; //TODO } } public static OKBQueryService.EqualityComparison GetEqualityComparisonForValue(string comparisonValue) { int v = Int32.Parse(comparisonValue); switch (v) { case (int)OKBQueryService.EqualityComparison.Equal: return OKBQueryService.EqualityComparison.Equal; case (int)OKBQueryService.EqualityComparison.NotEqual: return OKBQueryService.EqualityComparison.NotEqual; default: return OKBQueryService.EqualityComparison.Equal; //TODO } } public static OKBQueryService.OrdinalComparison GetOrdinalComparisonForValue(string comparisonValue) { int v = Int32.Parse(comparisonValue); switch (v) { case (int)OKBQueryService.OrdinalComparison.Equal: return OKBQueryService.OrdinalComparison.Equal; case (int)OKBQueryService.OrdinalComparison.Greater: return OKBQueryService.OrdinalComparison.Greater; case (int)OKBQueryService.OrdinalComparison.GreaterOrEqual: return OKBQueryService.OrdinalComparison.GreaterOrEqual; case (int)OKBQueryService.OrdinalComparison.Less: return OKBQueryService.OrdinalComparison.Less; case (int)OKBQueryService.OrdinalComparison.NotEqual: return OKBQueryService.OrdinalComparison.NotEqual; case (int)OKBQueryService.OrdinalComparison.LessOrEqual: return OKBQueryService.OrdinalComparison.LessOrEqual; default: return OKBQueryService.OrdinalComparison.Equal; //TODO } } } }