public void Should_Exclude_In_Small_Group_Filter()
        {
            var SGFxml = SpecialContentUtils.CreateSpecialContent(1, "SGF-MockedXML.xml", null);

            SpecialContentId = SGFxml.Id;
            SpecialContentUtils.UpdateSpecialContent(SpecialContentId, SGFxml.Name, SGFxml.Name, "<?xml version=\"1.0\" encoding=\"utf-8\"?>  <SGF divisionid=\"30\" layout=\"SGF-Layout\" gutter=\"SGF-Gutter\">    <SGFSettings>     <SGFSetting name=\"SubmitText\" value=\"Find Groups\" />     <SGFSetting name=\"ShowHeaders\" value=\"true\" />     <SGFSetting name=\"TextSize\" value=\"18\" />     <SGFSetting name=\"FontFamily\" value=\"Verdana,Arial,Helvetica,sans-serif\" />     <SGFSetting name=\"BGColor\" value=\"#FFFFFF\" />     <SGFSetting name=\"FGColor\" value=\"#000000\" />  </SGFSettings>    <SGFFilters>     <SGFFilter name=\"SGF:Gender\" title=\"Gender\" locked=\"false\" lockedvalue=\"\" />     <SGFFilter name=\"SGF:Childcare\" title=\"Childcare\" locked=\"false\" lockedvalue=\"\" />     <SGFFilter name=\"SGF:Location\" title=\"Location\" locked=\"false\" lockedvalue=\"\" />     <SGFFilter name=\"Campus\" title=\"Church\" locked=\"false\" lockedvalue=\"\" exclude=\"Do Not Attend\" />  </SGFFilters>    </SGF>", null, null, null);

            SettingUtils.UpdateSetting("SGF-OrgTypes", "MockedOrgType, Do Not Attend");

            SmallGroupFinderModel m = new SmallGroupFinderModel();

            m.load("MockedXML");

            var filter = m.getFilterItems(3);

            filter[0].value.ShouldBe("-- All --");
        }
示例#2
0
        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);
            }

            return(View(sgfm));
        }
示例#3
0
        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 = CurrentDatabase.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);
        }
        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));
            }
        }