public ActionResult Index(string id) { var check = (from e in DbUtil.Db.Contents where e.Name == "SGF-" + id + ".xml" select e).SingleOrDefault(); if (check == null) return new HttpNotFoundResult("Page not found!"); SmallGroupFinderModel sgfm = new SmallGroupFinderModel(); sgfm.load(id); if (Request.Form.Count == 0) { sgfm.setDefaultSearch(); } else { Dictionary<string, string> post = new Dictionary<string, string>(); foreach (string item in Request.Form) { if (item.StartsWith("SGF:")) post.Add(item, Request[item]); } sgfm.setSearch(post); } if (sgfm.hasShell()) // Process shell here return Content(sgfm.createFromShell()); else return View(sgfm); }
public ActionResult Index(string id) { var check = (from e in DbUtil.Db.Contents where e.Name == "SGF-" + id + ".xml" select e).SingleOrDefault(); if (check == null) return new HttpNotFoundResult("Page not found!"); SmallGroupFinderModel sgfm = new SmallGroupFinderModel(); sgfm.load(id); if (Request.Form.Count == 0) { //sgfm.setDefaultSearch(); } else { var search = new Dictionary<string, SearchItem>(); var encoded = Request.Form.ToString(); foreach (string item in encoded.Split('&')) { if (item.StartsWith("SGF")) { var parts = item.Split('='); if (parts.Count() == 2) { parts[0] = HttpUtility.UrlDecode(parts[0]); parts[1] = HttpUtility.UrlDecode(parts[1]); if (search.ContainsKey(parts[0])) { search[parts[0]].values.Add(parts[1]); search[parts[0]].parse = true; } else { search.Add(parts[0], new SearchItem() { name = parts[0], values = { parts[1] } }); } } } } sgfm.setSearch(search); } if (sgfm.hasShell()) // Process shell here return Content(sgfm.createFromShell()); else return View(sgfm); }
private SmallGroupFinderModel BuildSmallGroupFinderModel(string id, bool useShell = true) { var sgfm = new SmallGroupFinderModel(this, useShell); sgfm.load(id); var search = new Dictionary<string, SearchItem>(); var loadAllValues = DbUtil.Db.Setting("SGF-LoadAllExtraValues"); if (Request.Form.Count != 0) { var encoded = Request.Form.ToString(); foreach (var item in encoded.Split('&')) { if (!item.StartsWith("SGF") && !loadAllValues) continue; var parts = item.Split('='); if (parts.Count() != 2) continue; parts[0] = HttpUtility.UrlDecode(parts[0]); parts[1] = HttpUtility.UrlDecode(parts[1]); if (search.ContainsKey(parts[0])) { search[parts[0]].values.Add(parts[1]); search[parts[0]].parse = true; } else { search.Add(parts[0], new SearchItem { name = parts[0], values = { parts[1] } }); } } } foreach (var query in Request.QueryString.AllKeys.Where(x => x.ToLower() != "id")) { if (!query.StartsWith("SGF") && !loadAllValues) continue; if (search.ContainsKey(query)) { search[query].values.Clear(); search[query].values.Add(Request.QueryString[query]); } else { search.Add(query, new SearchItem { name = query, values = { Request.QueryString[query] } }); } } sgfm.setSearch(search); return sgfm; }