- Timestamp:
- 05/02/11 21:40:26 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs
r6097 r6102 18 18 // GET: /Filter/ 19 19 20 21 20 [ChildActionOnly] 22 21 public ActionResult Filters() 23 22 { 23 // Model 24 FilterModel qm = new FilterModel(); 25 26 27 //TODO nicht immer laden 28 QueryServiceClient client = Query.GetClientFactory("okbtester", "okbtester"); 29 List<Filter> filterList = client.GetFilters().ToList(); 30 qm.Filters = filterList; 31 qm.SelectedFilters = new List<Filter>(); 32 33 24 34 // For ModelViewuUserControl 25 return PartialView("Filters" ); // name of usercontrol35 return PartialView("Filters", qm); // name of usercontrol 26 36 } 37 38 //List<Filter> currentFilters 39 40 [ChildActionOnly] 41 public ActionResult Filters(FilterModel qms) 42 { 43 // Model 44 FilterModel qm = new FilterModel(); 45 46 47 //TODO nicht immer laden 48 QueryServiceClient client = Query.GetClientFactory("okbtester", "okbtester"); 49 List<Filter> filterList = client.GetFilters().ToList(); 50 qm.Filters = filterList; 51 qm.SelectedFilters =qms.SelectedFilters; 52 if (qm.SelectedFilters == null) 53 { 54 55 qm.SelectedFilters = new List<Filter>(); 56 } 57 58 59 60 // For ModelViewuUserControl 61 return PartialView("Filters", qm); // name of usercontrol 62 } 63 64 65 27 66 28 67 … … 35 74 public ActionResult AddFilter(FormCollection collection) 36 75 { 76 77 37 78 // Model 38 79 FilterModel qm = new FilterModel(); … … 46 87 // Selected filter (from combobox) 47 88 string filterType = collection.Get("filtersCombobox"); 48 Filter filter = filterList.Where(x => x.FilterTypeName.Equals(filterType)).First(); 89 90 if (filterType != null) 91 { 92 93 Filter filter = filterList.Where(x => x.FilterTypeName.CompareTo(filterType) == 0).First(); 49 94 50 95 51 // Get selected filters form session 52 qm.SelectedFilters = (List<Filter>)Session["selectedFilters"]; 96 if (filter != null) 97 { 98 // Get selected filters form session 99 qm.SelectedFilters = (List<Filter>)Session["selectedFilters"]; 100 if (qm.SelectedFilters == null) 101 { 53 102 54 // Add Filter only if not exists 55 if (qm.SelectedFilters.Where(x => x.FilterTypeName.Equals(filter.FilterTypeName)).Count() == 0) 56 { 103 qm.SelectedFilters = new List<Filter>(); 104 } 57 105 58 qm.SelectedFilters.Add(filter);59 }60 106 61 // Set values for the selected filters 62 foreach (string s in collection.AllKeys) 63 { 64 if (s.StartsWith("valueTextbox")) 65 { 66 // Get the type of the textbox 67 string type = s.Substring(s.IndexOf(".") + 1); 107 // Add Filter only if not exists 108 if (qm.SelectedFilters.Where(x => x.FilterTypeName.Equals(filter.FilterTypeName)).Count() == 0) 109 { 68 110 69 // Get the filter from the selected filters to set the value(s) 70 Filter f = qm.SelectedFilters.Where(x => x.GetType().Name.Equals(type)).First(); 71 if ("StringComparisonFilter".Equals(type)) 111 qm.SelectedFilters.Add(filter); 112 } 113 114 // Set values for the selected filters 115 foreach (string s in collection.AllKeys) 72 116 { 73 ((StringComparisonFilter)f).Value = collection.Get(s); 117 if (s.StartsWith("valueTextbox")) 118 { 119 // Get the type of the textbox 120 string type = s.Substring(s.IndexOf(".") + 1); 121 122 // Get the filter from the selected filters to set the value(s) 123 Filter f = qm.SelectedFilters.Where(x => x.GetType().Name.Equals(type)).First(); 124 if ("StringComparisonFilter".Equals(type)) 125 { 126 ((StringComparisonFilter)f).Value = collection.Get(s); 127 } 128 else if ("NameStringComparisonFilter".Equals(type)) 129 { 130 ((NameStringComparisonFilter)f).Value = collection.Get(s); 131 } 132 else if ("CombinedFilter".Equals(type)) 133 { 134 //((CombinedFilter)f).Filters 135 } 136 // TODO: add for all filter types and will the values (etc.) 137 } 74 138 } 75 else if ("NameStringComparisonFilter".Equals(type))76 {77 ((NameStringComparisonFilter)f).Value = collection.Get(s);78 }79 // TODO: add for all filter types and will the values (etc.)80 139 } 81 140 } 82 83 141 84 142
Note: See TracChangeset
for help on using the changeset viewer.