Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 6190 was 6190, checked in by dhohl, 12 years ago

#1499 refactor, first part of the comparison combobox for the different filters, Controls for the Filters

File size: 3.6 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        public static List<ComparisonItem> ordinalComparisons = new List<ComparisonItem>()
25        { new ComparisonItem((int)OKBQueryService.OrdinalComparison.Less, ORDINAL_COMPARISONS_LESS),
26          new ComparisonItem((int)OKBQueryService.OrdinalComparison.LessOrEqual, ORDINAL_COMPARISONS_LESS_OR_EQUAL),
27          new ComparisonItem((int)OKBQueryService.OrdinalComparison.Equal, ORDINAL_COMPARISONS_EQUAL),
28          new ComparisonItem((int)OKBQueryService.OrdinalComparison.GreaterOrEqual, ORDINAL_COMPARISONS_GREATER_OR_EQUAL),
29          new ComparisonItem((int)OKBQueryService.OrdinalComparison.Greater, ORDINAL_COMPARISONS_GREATER),
30          new ComparisonItem((int)OKBQueryService.OrdinalComparison.NotEqual, ORDINAL_COMPARISONS_NOT_EQUAL)
31        };
32        public static List<ComparisonItem> stringComparisons = new List<ComparisonItem>() {
33           new ComparisonItem((int)OKBQueryService.StringComparison.Equal, STRING_COMPARISONS_EQUAL),
34           new ComparisonItem((int)OKBQueryService.StringComparison.NotLike, STRING_COMPARISONS_NOT_EQUAL),
35           new ComparisonItem((int)OKBQueryService.StringComparison.Contains, STRING_COMPARISONS_CONTAINS),
36           new ComparisonItem((int)OKBQueryService.StringComparison.NotContains, STRING_COMPARISONS_NOT_CONTAINS),
37           new ComparisonItem((int)OKBQueryService.StringComparison.Like, STRING_COMPARISONS_LIKE),
38           new ComparisonItem((int)OKBQueryService.StringComparison.NotLike, STRING_COMPARISONS_NOT_LIKE)
39         };
40
41
42        public static OKBQueryService.StringComparison GetStringComparisonForValue(string comparisonValue)
43        {
44            int v = Int32.Parse(comparisonValue);
45
46            switch (v)
47            {
48                case (int)OKBQueryService.StringComparison.Equal:
49                    return OKBQueryService.StringComparison.Equal;
50                case (int)OKBQueryService.StringComparison.Contains:
51                    return OKBQueryService.StringComparison.Contains;
52                case (int)OKBQueryService.StringComparison.Like:
53                    return OKBQueryService.StringComparison.Like;
54                case (int)OKBQueryService.StringComparison.NotContains:
55                    return OKBQueryService.StringComparison.NotContains;
56                case (int)OKBQueryService.StringComparison.NotEqual:
57                    return OKBQueryService.StringComparison.NotEqual;
58                case (int)OKBQueryService.StringComparison.NotLike:
59                    return OKBQueryService.StringComparison.NotLike;
60                default:
61                    return OKBQueryService.StringComparison.Equal; //TODO
62            }
63        }
64    }
65}
Note: See TracBrowser for help on using the repository browser.