Changeset 6305
- Timestamp:
- 05/27/11 16:58:15 (13 years ago)
- Location:
- branches/WebApplication/MVC2/HLWebOKBQueryPlugin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs
r6303 r6305 27 27 FilterModel fm = new FilterModel(); 28 28 fm.Content = (CombinedFilter)Session["Content"]; 29 30 29 QueryServiceClient client = Query.GetClientFactory(); 31 32 30 33 31 long[] ids = client.GetRunIds(fm.Content); 34 32 … … 38 36 return View("Results", qm); // name of usercontrol 39 37 } 40 41 38 42 39 43 40 public ActionResult Filters(CombinedFilter f) … … 66 63 if ("add".Equals(submitAction)) 67 64 { 68 // string stringid = submitButton.Substring(2);69 65 string stringid = collection.Get("selectedFilter"); 70 66 AddNewFilter(collection, fm, stringid); … … 73 69 { 74 70 string stringid= collection.Get("selectedFilter"); 75 // string stringid = submitButton.Substring(2); 76 DeleteFilter(new Guid(stringid)); 71 DeleteFilter(new Guid(stringid)); 77 72 } 78 73 else if ("runs".Equals(submitAction)) … … 87 82 // Set Content 88 83 Session["Content"] = fm.Content; 89 90 84 return View("Index", fm); 91 85 92 86 } 93 87 88 94 89 private void AddNewFilter(FormCollection collection, FilterModel fm, String idKey) 95 { 96 // Add Filter 97 //String idKey = null; 90 { 98 91 String parentIdKey = idKey; 99 100 //foreach (string key in collection.AllKeys)101 //{102 // //if (key.StartsWith(FilterModel.ComboboxName))103 // //{104 // // idKey = key;105 // //}106 // if (key.StartsWith(FilterModel.ParentIdName))107 // {108 // parentIdKey = key;109 // }110 //}111 92 112 93 Guid parentId = new Guid(parentIdKey); 113 94 string filterTypeName = collection.Get(FilterModel.ComboboxName+ "." + idKey); 114 fm.AddFilter(filterTypeName, parentId); 115 116 //UpdateModel(collection, fm); 117 118 //// Set Content 119 //Session["Content"] = fm.Content; 120 121 //return View("Index", fm); 95 fm.AddFilter(filterTypeName, parentId); 122 96 } 123 97 … … 145 119 foreach (string key in collection.AllKeys) 146 120 { 147 148 121 if (!key.StartsWith(FilterModel.ComboboxName) && !key.StartsWith(FilterModel.ParentIdName)) 149 122 { … … 174 147 175 148 176 177 178 149 /// <summary> 179 150 /// Delete a filter with given id. … … 186 157 FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]); 187 158 188 //throw new Exception();189 190 159 // Remove Filter 191 bool filterRemoved = fm.RemoveFilter(id); 192 193 194 //UpdateModel(collection, fm); 195 // TODO Model muss auch beim löschen upgeadatet werden UpdateModel(collection, fm); 196 197 // Set Content 198 //Session["Content"] = fm.Content; 199 200 //return View("Index", fm); 201 } 202 203 204 160 bool filterRemoved = fm.RemoveFilter(id); 161 } 162 205 163 206 164 /// <summary> … … 209 167 /// <returns></returns> 210 168 public void AddFilterOr(FilterModel fm) 211 { 212 169 { 213 170 List<Filter> orFilters = fm.Content.Filters.ToList<Filter>(); ; 214 171 … … 216 173 orFilters.Add(andFilter); 217 174 fm.Content.Filters = orFilters.ToArray<Filter>(); 218 219 // TODO Model muss auch beim löschen upgeadatet werden UpdateModel(collection, fm); 220 221 Session["Content"] = fm.Content; 222 223 //return View("Index", fm); 224 } 225 226 175 176 Session["Content"] = fm.Content; 177 } 227 178 228 179 … … 236 187 public ActionResult Index() 237 188 { 238 239 189 // Set submenu 240 190 Session["SelectedSubMenu"] = "Filter"; 241 191 FilterModel fm = new FilterModel(); 242 243 192 244 193 // Init session variable for selected filters … … 257 206 fm.Content = f; 258 207 259 260 208 return View(fm); 261 209 } 262 263 264 210 } 265 211 } -
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Models/FilterModel.cs
r6303 r6305 17 17 public class FilterModel 18 18 { 19 20 21 22 19 public static string ComboboxName { get { return "filtersCombobox"; } } 23 20 public static string ParentIdName { get { return "parentId"; } } … … 35 32 public FilterModel() 36 33 { 37 38 34 } 39 35 … … 51 47 { 52 48 List<Boolean> boolStates = new List<Boolean>(); 53 54 49 boolStates = new List<Boolean>(); 55 50 boolStates.Add(true); 56 51 boolStates.Add(false); 57 58 52 return boolStates; 59 53 } 60 54 } 61 62 55 63 56 public static List<ComparisonItem> BoolComparisons 64 57 { … … 75 68 get { return ComparisonsHelper.stringComparisons; } 76 69 } 77 78 79 70 80 71 81 72 /// <summary> … … 118 109 /// </summary> 119 110 public CombinedFilter Content { get; set; } 120 121 111 122 112 123 113 /// <summary> … … 154 144 internal void AddFilter(string filterTypeName, Guid parentId) 155 145 { 156 157 146 // get selected filter (combobox) 158 147 Filter filter = AvailableFilters.Where(x => x.FilterTypeName.Equals(filterTypeName)).FirstOrDefault(); 159 160 148 161 149 // find the partent filterr … … 167 155 168 156 List<Filter> filterList = parentFilter.Filters.ToList<Filter>(); 169 170 157 171 158 // Add the new filter 172 159 filterList.Add(filter); … … 181 168 } 182 169 170 183 171 /// <summary> 184 172 /// Update existing filters with posted value … … 193 181 foreach (Filter f in cf.Filters) 194 182 { 195 196 183 Dictionary<string, string> dict = postValues.Where(x => x.Key.Equals(f.Id)).FirstOrDefault().Value; 197 184 if (dict != null) 198 185 { 199 200 186 foreach (KeyValuePair<string, string> kvp in dict) 201 187 { … … 350 336 } 351 337 } 352 353 354 338 else 355 339 { 356 340 // To this for all filters 357 341 } 358 359 360 342 } 361 362 363 343 } 364 344 }
Note: See TracChangeset
for help on using the changeset viewer.