Exemplo n.º 1
0
        public static List <int> GetCustomStatementsList(CMSDataContext db, string name)
        {
            if (name == "all")
            {
                return(null);
            }
            var xd = XDocument.Parse(Util.PickFirst(db.ContentOfTypeText("CustomStatements"), "<CustomStatement/>"));

            var standardsetlabel = db.Setting("StandardFundSetName", "Standard Statements");

            var allfunds = db.ContributionFunds.Select(cc => cc.FundId).ToList();

            if (name == standardsetlabel)
            {
                var standardFunds = allfunds.Select(vv => vv).ToList();
                foreach (var ele in xd.Descendants("Statement"))
                {
                    var f    = ele.Element("Funds")?.Value ?? "";
                    var list = GetFundSet(f, allfunds);
                    standardFunds.RemoveAll(vv => list.Contains(vv));
                }
                return(standardFunds);
            }
            var funds = xd.XPathSelectElement($"//Statement[@description=\"{name}\"]/Funds")?.Value ?? "";

            return(GetFundSet(funds, allfunds));
        }
Exemplo n.º 2
0
        public static StatementSpecification GetStatementSpecification(CMSDataContext db, string name)
        {
            var standardheader = db.ContentHtml("StatementHeader", Resource1.ContributionStatementHeader);
            var standardnotice = db.ContentHtml("StatementNotice", Resource1.ContributionStatementNotice);

            if (name == null || name == "all")
            {
                return(new StatementSpecification()
                {
                    Description = "All Statements",
                    Notice = standardnotice,
                    Header = standardheader,
                    Funds = null
                });
            }
            var standardsetlabel = db.Setting("StandardFundSetName", "Standard Statements");

            if (name == standardsetlabel)
            {
                var funds = APIContributionSearchModel.GetCustomStatementsList(db, name);
                return(new StatementSpecification()
                {
                    Description = standardsetlabel,
                    Notice = standardnotice,
                    Header = standardheader,
                    Funds = funds
                });
            }
            var xd  = XDocument.Parse(Util.PickFirst(db.ContentOfTypeText("CustomStatements"), "<CustomStatement/>"));
            var ele = xd.XPathSelectElement($"//Statement[@description='{name}']");

            if (ele == null)
            {
                return(null);
            }

            var desc = ele.Attribute("description")?.Value;
            var cs   = new StatementSpecification
            {
                Description = desc
            };
            var headerele = ele.Element("Header");

            cs.Header = headerele != null
                ? string.Concat(headerele.Nodes().Select(x => x.ToString()).ToArray())
                : standardheader;

            var noticeele = ele.Element("Notice");

            cs.Notice = noticeele != null
                ? string.Concat(noticeele.Nodes().Select(x => x.ToString()).ToArray())
                : standardnotice;

            cs.Funds = APIContributionSearchModel.GetCustomStatementsList(db, desc);
            return(cs);
        }
Exemplo n.º 3
0
        public static List <string> CustomFundSetList(CMSDataContext db)
        {
            var xd   = XDocument.Parse(Util.PickFirst(db.ContentOfTypeText("CustomFundSets"), "<CustomFundSets/>"));
            var list = xd.Descendants().Elements("FundSet").Select(ele => ele.Attribute("description")?.Value).ToList();

            var xd2 = XDocument.Parse(Util.PickFirst(db.ContentOfTypeText("CustomStatements"), "<CustomStatements/>"));

            if (!xd2.Descendants().Elements("Statement").Any())
            {
                return(list.Count == 0 ? null : list);
            }

            var standardsetlabel = db.Setting("StandardFundSetName", "Standard Statements");

            list.Add(standardsetlabel);
            list.AddRange(xd2.Descendants().Elements("Statement").Select(ele => ele.Attribute("description")?.Value));

            return(list.Count == 0 ? null : list);
        }
        public static StatementSpecification GetStatementSpecification(CMSDataContext db, string name)
        {
            string nameOfChurch   = db.Setting("NameOfChurch", "Name of Church");
            string startAddress   = db.Setting("StartAddress", "Start Address");
            string churchPhone    = db.Setting("ChurchPhone", "(000) 000-0000");
            var    standardheader = db.ContentHtml("StatementHeader", string.Format(Resource1.ContributionStatementHeader, nameOfChurch, startAddress, churchPhone));
            var    standardnotice = db.ContentHtml("StatementNotice", string.Format(Resource1.ContributionStatementNotice, nameOfChurch));

            if (name == null || name == "all")
            {
                return(new StatementSpecification()
                {
                    Notice = standardnotice,
                    Header = standardheader,
                    Funds = null
                });
            }
            var standardsetlabel = db.Setting("StandardFundSetName", "Standard Statements");

            if (name == standardsetlabel)
            {
                var funds = APIContributionSearchModel.GetCustomStatementsList(db, name);
                return(new StatementSpecification()
                {
                    Description = standardsetlabel,
                    Notice = standardnotice,
                    Header = standardheader,
                    Funds = funds
                });
            }
            var xd            = XDocument.Parse(Util.PickFirst(db.ContentOfTypeText("CustomStatements"), "<CustomStatement/>"));
            var statementSpec = xd.XPathSelectElement($"//Statement[@description='{name}']");

            if (statementSpec == null)
            {
                return(null);
            }

            var desc = statementSpec.Attribute("description")?.Value;
            var cs   = new StatementSpecification
            {
                Description = desc
            };

            cs.Funds        = APIContributionSearchModel.GetCustomStatementsList(db, desc);
            cs.Header       = GetSectionHTML(db, "Header", statementSpec, standardheader);
            cs.Notice       = GetSectionHTML(db, "Notice", statementSpec, standardnotice);
            cs.Template     = GetSectionHTML(db, "Template", statementSpec);
            cs.TemplateBody = GetSectionHTML(db, "TemplateBody", statementSpec);
            cs.Footer       = GetSectionHTML(db, "Footer", statementSpec);

            return(cs);
        }
Exemplo n.º 5
0
        public static List <string> CustomStatementsList(CMSDataContext db)
        {
            var xd   = XDocument.Parse(Util.PickFirst(db.ContentOfTypeText("CustomStatements"), "<CustomStatement/>"));
            var list = new List <string>();

            foreach (var ele in xd.Descendants().Elements("Statement"))
            {
                list.Add(ele.Attribute("description")?.Value);
            }

            if (list.Count == 0)
            {
                return(null);
            }

            var standardsetlabel = db.Setting("StandardFundSetName", "Standard Statements");

            list.Insert(0, standardsetlabel);
            return(list);
        }
Exemplo n.º 6
0
        public static List <int> GetCustomFundSetList(CMSDataContext db, string name)
        {
            if (name == "all" || name == "(not specified)")
            {
                return(null);
            }
            var xd    = XDocument.Parse(Util.PickFirst(db.ContentOfTypeText("CustomFundSets"), "<CustomFundSets/>"));
            var funds = xd.XPathSelectElement($"//FundSet[@description=\"{name}\"]/Funds")?.Value ?? "";

            if (!funds.HasValue())
            {
                return(GetCustomStatementsList(db, name));
            }

            var allfunds = db.ContributionFunds.Select(cc => cc.FundId).ToList();

            return(funds.HasValue()
                ? GetFundSet(funds, allfunds)
                : GetCustomStatementsList(db, name));
        }