Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HLWebOKBQueryPlugin/ViewModels/ComparisonsHelper.cs @ 10207

Last change on this file since 10207 was 6245, checked in by dhohl, 14 years ago

#1499 Filter controls save the correct Comparison. Filter Label is correct.

File size: 7.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Web;
5
6namespace HLWebOKBQueryPlugin.ViewModels
7{
8    public class ComparisonsHelper
9    {
10        private static  String ORDINAL_COMPARISONS_LESS = "<";
11        private static  String ORDINAL_COMPARISONS_LESS_OR_EQUAL = "<=";
12        private static  String ORDINAL_COMPARISONS_EQUAL = "=";
13        private static  String ORDINAL_COMPARISONS_GREATER_OR_EQUAL = ">=";
14        private static  String ORDINAL_COMPARISONS_GREATER = ">";
15        private static  String ORDINAL_COMPARISONS_NOT_EQUAL = "<>";
16
17        private static String STRING_COMPARISONS_EQUAL = "=";
18        private static String STRING_COMPARISONS_NOT_EQUAL = "<>";
19        private static String STRING_COMPARISONS_CONTAINS = "contains";
20        private static String STRING_COMPARISONS_NOT_CONTAINS = "not contains";
21        private static String STRING_COMPARISONS_LIKE = "like";
22        private static String STRING_COMPARISONS_NOT_LIKE = "not like";
23
24        private static String BOOL_COMPARISONS_EQUAL = "=";
25        private static String BOOL_COMPARISONS_NOT_EQUAL = "<>";
26
27        public static List<ComparisonItem> boolComparisons = new List<ComparisonItem>()
28        { new ComparisonItem((int)OKBQueryService.EqualityComparison.Equal, BOOL_COMPARISONS_EQUAL),
29          new ComparisonItem((int)OKBQueryService.EqualityComparison.NotEqual, BOOL_COMPARISONS_NOT_EQUAL)
30        };
31        public static List<ComparisonItem> ordinalComparisons = new List<ComparisonItem>()
32        { new ComparisonItem((int)OKBQueryService.OrdinalComparison.Less, ORDINAL_COMPARISONS_LESS),
33          new ComparisonItem((int)OKBQueryService.OrdinalComparison.LessOrEqual, ORDINAL_COMPARISONS_LESS_OR_EQUAL),
34          new ComparisonItem((int)OKBQueryService.OrdinalComparison.Equal, ORDINAL_COMPARISONS_EQUAL),
35          new ComparisonItem((int)OKBQueryService.OrdinalComparison.GreaterOrEqual, ORDINAL_COMPARISONS_GREATER_OR_EQUAL),
36          new ComparisonItem((int)OKBQueryService.OrdinalComparison.Greater, ORDINAL_COMPARISONS_GREATER),
37          new ComparisonItem((int)OKBQueryService.OrdinalComparison.NotEqual, ORDINAL_COMPARISONS_NOT_EQUAL)
38        };
39        public static List<ComparisonItem> stringComparisons = new List<ComparisonItem>() {
40           new ComparisonItem((int)OKBQueryService.StringComparison.Equal, STRING_COMPARISONS_EQUAL),
41           new ComparisonItem((int)OKBQueryService.StringComparison.NotEqual, STRING_COMPARISONS_NOT_EQUAL),
42           new ComparisonItem((int)OKBQueryService.StringComparison.Contains, STRING_COMPARISONS_CONTAINS),
43           new ComparisonItem((int)OKBQueryService.StringComparison.NotContains, STRING_COMPARISONS_NOT_CONTAINS),
44           new ComparisonItem((int)OKBQueryService.StringComparison.Like, STRING_COMPARISONS_LIKE),
45           new ComparisonItem((int)OKBQueryService.StringComparison.NotLike, STRING_COMPARISONS_NOT_LIKE)
46         };
47
48
49        //public static String GetValueForStringComparision(OKBQueryService.StringComparison comparisionValue)
50        //{
51        //    switch (comparisionValue)
52        //    {
53        //        case OKBQueryService.StringComparison.Equal:
54        //            return STRING_COMPARISONS_EQUAL;
55        //        case OKBQueryService.StringComparison.Contains:
56        //            return STRING_COMPARISONS_CONTAINS;
57        //        case OKBQueryService.StringComparison.Like:
58        //            return STRING_COMPARISONS_LIKE;
59        //        case OKBQueryService.StringComparison.NotContains:
60        //            return STRING_COMPARISONS_NOT_CONTAINS;
61        //        case OKBQueryService.StringComparison.NotEqual:
62        //            return STRING_COMPARISONS_NOT_EQUAL;
63        //        case OKBQueryService.StringComparison.NotLike:
64        //            return STRING_COMPARISONS_NOT_LIKE;
65        //        default:
66        //            return STRING_COMPARISONS_EQUAL; //TODO
67        //    }
68        //}
69
70       
71
72
73
74        public static OKBQueryService.StringComparison GetStringComparisonForValue(string comparisonValue)
75        {
76            int v = Int32.Parse(comparisonValue);
77
78            switch (v)
79            {
80                case (int)OKBQueryService.StringComparison.Equal:
81                    return OKBQueryService.StringComparison.Equal;
82                case (int)OKBQueryService.StringComparison.Contains:
83                    return OKBQueryService.StringComparison.Contains;
84                case (int)OKBQueryService.StringComparison.Like:
85                    return OKBQueryService.StringComparison.Like;
86                case (int)OKBQueryService.StringComparison.NotContains:
87                    return OKBQueryService.StringComparison.NotContains;
88                case (int)OKBQueryService.StringComparison.NotEqual:
89                    return OKBQueryService.StringComparison.NotEqual;
90                case (int)OKBQueryService.StringComparison.NotLike:
91                    return OKBQueryService.StringComparison.NotLike;
92                default:
93                    return OKBQueryService.StringComparison.Equal; //TODO
94            }
95        }
96
97        public static OKBQueryService.EqualityComparison GetEqualityComparisonForValue(string comparisonValue)
98        {
99             int v = Int32.Parse(comparisonValue);
100
101             switch (v)
102             {
103                 case (int)OKBQueryService.EqualityComparison.Equal:
104                     return OKBQueryService.EqualityComparison.Equal;
105                 case (int)OKBQueryService.EqualityComparison.NotEqual:
106                     return OKBQueryService.EqualityComparison.NotEqual;
107                 default:
108                     return OKBQueryService.EqualityComparison.Equal; //TODO
109             }
110        }
111
112        public static OKBQueryService.OrdinalComparison GetOrdinalComparisonForValue(string comparisonValue)
113        {
114            int v = Int32.Parse(comparisonValue);
115
116         
117
118            switch (v)
119            {
120                case (int)OKBQueryService.OrdinalComparison.Equal:
121                    return OKBQueryService.OrdinalComparison.Equal;
122                case (int)OKBQueryService.OrdinalComparison.Greater:                   
123                    return OKBQueryService.OrdinalComparison.Greater;
124                case (int)OKBQueryService.OrdinalComparison.GreaterOrEqual:
125                    return OKBQueryService.OrdinalComparison.GreaterOrEqual;
126                case (int)OKBQueryService.OrdinalComparison.Less:
127                    return OKBQueryService.OrdinalComparison.Less;
128                case (int)OKBQueryService.OrdinalComparison.NotEqual:
129                    return OKBQueryService.OrdinalComparison.NotEqual;
130                case (int)OKBQueryService.OrdinalComparison.LessOrEqual:
131                    return OKBQueryService.OrdinalComparison.LessOrEqual;
132                default:                   
133                    return OKBQueryService.OrdinalComparison.Equal; //TODO
134            }
135
136           
137        }
138    }
139}
Note: See TracBrowser for help on using the repository browser.