- Timestamp:
- 05/22/11 21:01:58 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebApplication/MVC2/HLWebOKBQueryPlugin/Controllers/FilterController.cs
r6245 r6247 20 20 /// </summary> 21 21 /// <returns></returns> 22 public ActionResultGetRuns()22 public void GetRuns() 23 23 { 24 24 FilterModel qm = new FilterModel(); … … 32 32 Response.Write("Found <" + ids.Count() + "> Runs."); 33 33 34 return View("Index", qm); // name of usercontrol34 // return View("Index", qm); // name of usercontrol 35 35 } 36 36 … … 51 51 /// <param name="collection"></param> 52 52 /// <returns></returns> 53 public ActionResult AddFilterAnd( FormCollection collection)53 public ActionResult AddFilterAnd(string submitButton, FormCollection collection) 54 54 { 55 55 FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]); 56 56 57 58 // Add Filter 59 String idKey = null; 60 String parentIdKey = null; 61 62 foreach (string key in collection.AllKeys) 63 { 64 if (key.StartsWith(FilterModel.ComboboxName)) 65 { 66 idKey = key; 67 } 68 if (key.StartsWith(FilterModel.ParentIdName)) 69 { 70 parentIdKey = key; 71 } 72 } 73 74 Guid parentId = new Guid(collection.Get(parentIdKey)); 75 string filterTypeName = collection.Get(idKey); 76 fm.AddFilter(filterTypeName, parentId); 77 57 Response.Write("Submit:" + submitButton); 58 59 //update model with form data 78 60 UpdateModel(collection, fm); 79 61 62 if (submitButton.StartsWith("+")) 63 { 64 string stringid = submitButton.Substring(2); 65 AddNewFilter(collection, fm, stringid); 66 } 67 else if (submitButton.StartsWith("-")) 68 { 69 string stringid = submitButton.Substring(2); 70 DeleteFilter(new Guid(stringid)); 71 } 72 else if (submitButton.Equals("runs")) 73 { 74 GetRuns(); 75 } 76 else if (submitButton.Equals("or")) 77 { 78 AddFilterOr( fm); 79 } 80 80 81 // Set Content 81 82 Session["Content"] = fm.Content; 82 83 83 84 return View("Index", fm); 85 86 } 87 88 private void AddNewFilter(FormCollection collection, FilterModel fm, String idKey) 89 { 90 // Add Filter 91 //String idKey = null; 92 String parentIdKey = idKey; 93 94 //foreach (string key in collection.AllKeys) 95 //{ 96 // //if (key.StartsWith(FilterModel.ComboboxName)) 97 // //{ 98 // // idKey = key; 99 // //} 100 // if (key.StartsWith(FilterModel.ParentIdName)) 101 // { 102 // parentIdKey = key; 103 // } 104 //} 105 106 Guid parentId = new Guid(parentIdKey); 107 string filterTypeName = collection.Get(FilterModel.ComboboxName+ "." + idKey); 108 fm.AddFilter(filterTypeName, parentId); 109 110 //UpdateModel(collection, fm); 111 112 //// Set Content 113 //Session["Content"] = fm.Content; 114 115 //return View("Index", fm); 84 116 } 85 117 … … 111 143 { 112 144 int idx = key.IndexOf("."); 113 string id = key.Substring(0, idx); 114 string type = key.Substring(idx + 1); 115 116 Guid fid = new Guid(id); 117 118 if (postValues.ContainsKey(fid)) 145 if (idx != -1) 119 146 { 120 Dictionary<string, string> d = postValues[fid]; 121 d.Add(type, collection.Get(key)); 122 } 123 else 124 { 125 Dictionary<string, string> d = new Dictionary<string, string>(); 126 d.Add(type, collection.Get(key)); 127 postValues.Add(fid, d); 147 string id = key.Substring(0, idx); 148 string type = key.Substring(idx + 1); 149 150 Guid fid = new Guid(id); 151 152 if (postValues.ContainsKey(fid)) 153 { 154 Dictionary<string, string> d = postValues[fid]; 155 d.Add(type, collection.Get(key)); 156 } 157 else 158 { 159 Dictionary<string, string> d = new Dictionary<string, string>(); 160 d.Add(type, collection.Get(key)); 161 postValues.Add(fid, d); 162 } 128 163 } 129 164 } … … 140 175 /// <param name="id"></param> 141 176 /// <returns></returns> 142 public ActionResult DeleteFilter(Guid id)177 public void DeleteFilter(Guid id) 143 178 { 144 179 // Get Content from Session 145 180 FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]); 146 181 182 //throw new Exception(); 183 147 184 // Remove Filter 148 185 bool filterRemoved = fm.RemoveFilter(id); 149 186 187 188 //UpdateModel(collection, fm); 150 189 // TODO Model muss auch beim löschen upgeadatet werden UpdateModel(collection, fm); 151 190 152 191 // Set Content 153 Session["Content"] = fm.Content;154 155 return View("Index", fm);192 //Session["Content"] = fm.Content; 193 194 //return View("Index", fm); 156 195 } 157 196 … … 163 202 /// </summary> 164 203 /// <returns></returns> 165 public ActionResult AddFilterOr() 166 { 167 FilterModel fm = new FilterModel((CombinedFilter)Session["Content"]); 168 204 public void AddFilterOr(FilterModel fm) 205 { 206 169 207 List<Filter> orFilters = fm.Content.Filters.ToList<Filter>(); ; 170 208 … … 177 215 Session["Content"] = fm.Content; 178 216 179 return View("Index", fm);217 //return View("Index", fm); 180 218 } 181 219
Note: See TracChangeset
for help on using the changeset viewer.