ComputeTitle() public method

public ComputeTitle ( ) : string
return string
Example #1
0
        private string DoReplaceCode(string code, Person p, PayInfo pi = null, EmailQueueTo emailqueueto = null)
        {
            if (code.StartsWith("<style"))
                return code;
            switch (code.ToLower())
            {
                case "{address}":
                    return p.PrimaryAddress;

                case "{address2}":
                    if (p.PrimaryAddress2.HasValue())
                        return "<br>" + p.PrimaryAddress2;
                    return "";

                case "{amtdue}":
                    if (pi != null)
                        return pi.AmountDue.ToString2("c");
                    break;

                case "{amtpaid}":
                    if (pi != null)
                        return pi.AmountPaid.ToString2("c");
                    break;

                case "{amount}":
                    if (pi != null)
                        return pi.Amount.ToString2("c");
                    break;

                case "{barcode}":
                    return $"<img src='{db.ServerLink("/Track/Barcode/" + p.PeopleId)}' />";

                case "{campus}":
                    return p.CampusId != null ? p.Campu.Description : "No Campus Specified";

                case "{cellphone}":
                    return p.CellPhone.HasValue() ? p.CellPhone.FmtFone() : "no cellphone on record";

                case "{city}":
                    return p.PrimaryCity;

                case "{csz}":
                    return Util.FormatCSZ(p.PrimaryCity, p.PrimaryState, p.PrimaryZip);

                case "{country}":
                    return p.PrimaryCountry;

                case "{createaccount}":
                    if (emailqueueto != null)
                        return CreateUserTag(emailqueueto);
                    break;

                case "{church}":
                    return db.Setting("NameOfChurch", "Set this in NameOfChurch setting");

                case "{cmshost}":
                    return db.ServerLink();

                case "{dob}":
                    return p.DOB;

                case "{emailhref}":
                    if (emailqueueto != null)
                        return db.ServerLink("/EmailView/" + emailqueueto.Id);
                    break;

                case "{first}":
                    return p.PreferredName.Contains("?") || p.PreferredName.Contains("unknown", true) ? "" : p.PreferredName;

                case "{fromemail}":
                    return from.Address;

                case "{homephone}":
                    return p.HomePhone.HasValue() ? p.HomePhone.FmtFone() : "no homephone on record";

                case "{last}":
                    return p.LastName;

                case "{name}":
                    return p.Name.Contains("?") || p.Name.Contains("unknown", true) ? "" : p.Name;

                case "{nextmeetingtime}":
                    if (emailqueueto != null)
                        return NextMeetingDate(code, emailqueueto);
                    break;
                case "{nextmeetingtime0}":
                    if (emailqueueto != null)
                        return NextMeetingDate0(code, emailqueueto);
                    break;

                case "{occupation}":
                    return p.OccupationOther;

                case "{orgname}":
                case "{org}":
                    return GetOrgInfo(emailqueueto).Name;

                case "{orgmembercount}":
                    return GetOrgInfo(emailqueueto).Count;

                case "{paylink}":
                    if (pi != null && pi.PayLink.HasValue())
                        return $"<a href=\"{pi.PayLink}\">Click this link to make a payment and view your balance.</a>";
                    break;

                case "{peopleid}":
                    return p.PeopleId.ToString();

                case "{salutation}":
                    if (emailqueueto != null)
                        return db.GoerSupporters.Where(ee => ee.Id == emailqueueto.GoerSupportId).Select(ee => ee.Salutation).SingleOrDefault();
                    break;

                case "{state}":
                    return p.PrimaryState;

                case "{email}":
                case "{toemail}":
                    if (ListAddresses.Count > 0)
                        return ListAddresses[0].Address;
                    break;

                case "{today}":
                    return DateTime.Today.ToShortDateString();

                case "{title}":
                    if (p.TitleCode.HasValue())
                        return p.TitleCode;
                    return p.ComputeTitle();

                case "{track}":
                    if (emailqueueto != null)
                        return emailqueueto.Guid.HasValue ?
                            $"<img src=\"{db.ServerLink("/Track/Key/" + emailqueueto.Guid.Value.GuidToQuerystring())}\" />"
                            : "";
                    break;

                case "{unsubscribe}":
                    if (emailqueueto != null)
                        return UnSubscribeLink(emailqueueto);
                    break;

                default:
                    if (emailqueueto == null)
                        emailqueueto = new EmailQueueTo()
                        {
                            PeopleId = p.PeopleId,
                            OrgId = db.CurrentOrgId0
                        };

                    if (code.StartsWith("{addsmallgroup:", StringComparison.OrdinalIgnoreCase))
                        return AddSmallGroup(code, emailqueueto);

                    if (code.StartsWith("{extra", StringComparison.OrdinalIgnoreCase))
                        return ExtraValue(code, emailqueueto);

                    if (registerLinkRe.IsMatch(code))
                        return RegisterLink(code, emailqueueto);

                    if (registerHrefRe.IsMatch(code))
                        return RegisterLinkHref(code, emailqueueto);

                    if (registerTagRe.IsMatch(code))
                        return RegisterTag(code, emailqueueto);

                    if (rsvpLinkRe.IsMatch(code))
                        return RsvpLink(code, emailqueueto);

                    if (sendLinkRe.IsMatch(code))
                        return SendLink(code, emailqueueto);

                    if (code.StartsWith("{orgextra:", StringComparison.OrdinalIgnoreCase))
                        return OrgExtra(code, emailqueueto);

                    if (code.StartsWith("{orgmember:", StringComparison.OrdinalIgnoreCase))
                        return OrgMember(code, emailqueueto);

                    if (code.StartsWith("{orgbarcode"))
                        return OrgBarcode(code, emailqueueto);

                    if (code.StartsWith("{smallgroup:", StringComparison.OrdinalIgnoreCase))
                        return SmallGroup(code, emailqueueto);

                    if (regTextRe.IsMatch(code))
                        return RegText(code, emailqueueto);

                    if (code.StartsWith("{smallgroups", StringComparison.OrdinalIgnoreCase))
                        return SmallGroups(code, emailqueueto);

                    if (supportLinkRe.IsMatch(code))
                        return SupportLink(code, emailqueueto);

                    if (masterLinkRe.IsMatch(code))
                        return MasterLink(code, emailqueueto);

                    if (volReqLinkRe.IsMatch(code))
                        return VolReqLink(code, emailqueueto);

                    if (volSubLinkRe.IsMatch(code))
                        return VolSubLink(code, emailqueueto);

                    if (voteLinkRe.IsMatch(code))
                        return VoteLink(code, emailqueueto);

                    break;
            }

            return code;
        }
        private string DoReplaceCode(string code, Person p, PayInfo pi = null, EmailQueueTo emailqueueto = null)
        {
            if (code.StartsWith("<style"))
            {
                return(code);
            }
            switch (code.ToLower())
            {
            case "{address}":
                return(p.PrimaryAddress);

            case "{address2}":
                if (p.PrimaryAddress2.HasValue())
                {
                    return("<br>" + p.PrimaryAddress2);
                }
                return("");

            case "{amtdue}":
                if (pi != null)
                {
                    return(pi.AmountDue.ToString2("c"));
                }
                break;

            case "{amtpaid}":
                if (pi != null)
                {
                    return(pi.AmountPaid.ToString2("c"));
                }
                break;

            case "{amount}":
                if (pi != null)
                {
                    return(pi.Amount.ToString2("c"));
                }
                break;

            case "{barcode}":
                return($"<img src='{db.ServerLink("/Track/Barcode/" + p.PeopleId)}' />");

            case "{campus}":
                return(p.CampusId != null ? p.Campu.Description : $"No {Util2.CampusLabel} Specified");

            case "{cellphone}":
                return(p.CellPhone.HasValue() ? p.CellPhone.FmtFone() : "no cellphone on record");

            case "{city}":
                return(p.PrimaryCity);

            case "{csz}":
                return(Util.FormatCSZ(p.PrimaryCity, p.PrimaryState, p.PrimaryZip));

            case "{country}":
                return(p.PrimaryCountry);

            case "{createaccount}":
                if (emailqueueto != null)
                {
                    return(CreateUserTag(emailqueueto));
                }
                break;

            case "{church}":
                return(db.Setting("NameOfChurch", "Set this in NameOfChurch setting"));

            case "{cmshost}":
                return(db.ServerLink());

            case "{dob}":
                return(p.DOB);

            case "{estatement}":
                if (p.ElectronicStatement == true)
                {
                    return("Online Electronic Statement Only");
                }
                else
                {
                    return("Printed Statement in Addition to Online Option");
                }

            case "{emailhref}":
                if (emailqueueto != null)
                {
                    return(db.ServerLink("/EmailView/" + emailqueueto.Id));
                }
                break;

            case "{first}":
                return(p.PreferredName.Contains("?") || p.PreferredName.Contains("unknown", true) ? "" : p.PreferredName);

            case "{fromemail}":
                return(from.Address);

            case "{homephone}":
                return(p.HomePhone.HasValue() ? p.HomePhone.FmtFone() : "no homephone on record");

            case "{last}":
                return(p.LastName);

            case "{name}":
                return(p.Name.Contains("?") || p.Name.Contains("unknown", true) ? "" : p.Name);

            case "{nextmeetingtime}":
                if (emailqueueto != null)
                {
                    return(NextMeetingDate(code, emailqueueto));
                }
                break;

            case "{nextmeetingtime0}":
                if (emailqueueto != null)
                {
                    return(NextMeetingDate0(code, emailqueueto));
                }
                break;

            case "{occupation}":
                return(p.OccupationOther);

            case "{orgname}":
            case "{org}":
                return(GetOrgInfo(emailqueueto).Name);

            case "{orgmembercount}":
                return(GetOrgInfo(emailqueueto).Count);

            case "{paylink}":
                if (pi != null && pi.PayLink.HasValue())
                {
                    return($"<a href=\"{pi.PayLink}\">Click this link to make a payment and view your balance.</a>");
                }
                break;

            case "{peopleid}":
                return(p.PeopleId.ToString());

            case "{receivesms}":
                if (p.ReceiveSMS == true)
                {
                    return("Yes");
                }
                else
                {
                    return("No");
                }

            case "{salutation}":
                if (emailqueueto != null)
                {
                    return(db.GoerSupporters.Where(ee => ee.Id == emailqueueto.GoerSupportId).Select(ee => ee.Salutation).SingleOrDefault());
                }
                break;

            case "{state}":
                return(p.PrimaryState);

            case "{statementtype}":
                var stmtcode = p.ContributionOptionsId;
                switch (stmtcode)
                {
                case CmsData.Codes.StatementOptionCode.Individual:
                    return("Individual");

                case CmsData.Codes.StatementOptionCode.Joint:
                    return("Joint");

                case CmsData.Codes.StatementOptionCode.None:
                default:
                    return("None");
                }


            case "{email}":
            case "{toemail}":
                if (ListAddresses.Count > 0)
                {
                    return(ListAddresses[0].Address);
                }
                break;

            case "{today}":
                return(DateTime.Today.ToShortDateString());

            case "{title}":
                if (p.TitleCode.HasValue())
                {
                    return(p.TitleCode);
                }
                return(p.ComputeTitle());

            case "{track}":
                if (emailqueueto != null)
                {
                    return(emailqueueto.Guid.HasValue ?
                           $"<img src=\"{db.ServerLink("/Track/Key/" + emailqueueto.Guid.Value.GuidToQuerystring())}\" />"
                            : "");
                }
                break;

            case "{unsubscribe}":
                if (emailqueueto != null)
                {
                    return(UnSubscribeLink(emailqueueto));
                }
                break;

            default:
                if (emailqueueto == null)
                {
                    emailqueueto = new EmailQueueTo()
                    {
                        PeopleId = p.PeopleId,
                        OrgId    = db.CurrentOrgId0
                    }
                }
                ;

                if (code.StartsWith("{addsmallgroup:", StringComparison.OrdinalIgnoreCase))
                {
                    return(AddSmallGroup(code, emailqueueto));
                }

                if (code.StartsWith("{extra", StringComparison.OrdinalIgnoreCase))
                {
                    return(ExtraValue(code, emailqueueto));
                }

                if (registerLinkRe.IsMatch(code))
                {
                    return(RegisterLink(code, emailqueueto));
                }

                if (registerHrefRe.IsMatch(code))
                {
                    return(RegisterLinkHref(code, emailqueueto));
                }

                if (registerTagRe.IsMatch(code))
                {
                    return(RegisterTag(code, emailqueueto));
                }

                if (rsvpLinkRe.IsMatch(code))
                {
                    return(RsvpLink(code, emailqueueto));
                }

                if (sendLinkRe.IsMatch(code))
                {
                    return(SendLink(code, emailqueueto));
                }

                if (code.StartsWith("{orgextra:", StringComparison.OrdinalIgnoreCase))
                {
                    return(OrgExtra(code, emailqueueto));
                }

                if (code.StartsWith("{orgmember:", StringComparison.OrdinalIgnoreCase))
                {
                    return(OrgMember(code, emailqueueto));
                }

                if (code.StartsWith("{orgbarcode"))
                {
                    return(OrgBarcode(code, emailqueueto));
                }

                if (code.StartsWith("{smallgroup:", StringComparison.OrdinalIgnoreCase))
                {
                    return(SmallGroup(code, emailqueueto));
                }
                if (code.StartsWith("{subgroup:", StringComparison.OrdinalIgnoreCase))
                {
                    return(SmallGroup(code, emailqueueto));
                }

                if (regTextRe.IsMatch(code))
                {
                    return(RegText(code, emailqueueto));
                }

                if (code.StartsWith("{smallgroups", StringComparison.OrdinalIgnoreCase))
                {
                    return(SmallGroups(code, emailqueueto));
                }
                if (code.StartsWith("{subgroups", StringComparison.OrdinalIgnoreCase))
                {
                    return(SmallGroups(code, emailqueueto));
                }

                if (supportLinkRe.IsMatch(code))
                {
                    return(SupportLink(code, emailqueueto));
                }

                if (masterLinkRe.IsMatch(code))
                {
                    return(MasterLink(code, emailqueueto));
                }

                if (volReqLinkRe.IsMatch(code))
                {
                    return(VolReqLink(code, emailqueueto));
                }

                if (volSubLinkRe.IsMatch(code))
                {
                    return(VolSubLink(code, emailqueueto));
                }

                if (voteLinkRe.IsMatch(code))
                {
                    return(VoteLink(code, emailqueueto));
                }

                break;
            }

            return(code);
        }
Example #3
0
 private string Title(Person p) => p.TitleCode.HasValue() ? p.TitleCode : p.ComputeTitle();
Example #4
0
        private string DoReplaceCode(string code, Person p, PayInfo pi = null, EmailQueueTo emailqueueto = null)
        {
            switch (code.ToLower())
            {
            case "{address}":
                return(p.PrimaryAddress);

            case "{address2}":
                if (p.PrimaryAddress2.HasValue())
                {
                    return("<br>" + p.PrimaryAddress2);
                }
                return("");

            case "{amtdue}":
                if (pi != null)
                {
                    return(pi.AmountDue.ToString2("c"));
                }
                break;

            case "{amtpaid}":
                if (pi != null)
                {
                    return(pi.AmountPaid.ToString2("c"));
                }
                break;

            case "{amount}":
                if (pi != null)
                {
                    return(pi.Amount.ToString2("c"));
                }
                break;

            case "{barcode}":
                return(string.Format("<img src='{0}' />", db.ServerLink("/Track/Barcode/" + p.PeopleId)));

            case "{campus}":
                return(p.CampusId != null ? p.Campu.Description : "No Campus Specified");

            case "{cellphone}":
                return(p.CellPhone.HasValue() ? p.CellPhone.FmtFone() : "no cellphone on record");

            case "{city}":
                return(p.PrimaryCity);

            case "{csz}":
                return(Util.FormatCSZ(p.PrimaryCity, p.PrimaryState, p.PrimaryZip));

            case "{country}":
                return(p.PrimaryCountry);

            case "{createaccount}":
                if (emailqueueto != null)
                {
                    return(CreateUserTag(emailqueueto));
                }
                break;

            case "{cmshost}":
                return(db.ServerLink());

            case "{emailhref}":
                if (emailqueueto != null)
                {
                    return(db.ServerLink("/EmailView/" + emailqueueto.Id));
                }
                break;

            case "{first}":
                return(p.PreferredName.Contains("?") || p.PreferredName.Contains("unknown", true) ? "" : p.PreferredName);

            case "{fromemail}":
                return(from.Address);

            case "{homephone}":
                return(p.HomePhone.HasValue() ? p.HomePhone.FmtFone() : "no homephone on record");

            case "{last}":
                return(p.LastName);

            case "{name}":
                return(p.Name.Contains("?") || p.Name.Contains("unknown", true) ? "" : p.Name);

            case "{nextmeetingtime}":
                if (emailqueueto != null)
                {
                    return(NextMeetingDate(code, emailqueueto));
                }
                break;

            case "{nextmeetingtime0}":
                if (emailqueueto != null)
                {
                    return(NextMeetingDate0(code, emailqueueto));
                }
                break;

            case "{occupation}":
                return(p.OccupationOther);

            case "{orgname}":
            case "{org}":
                return(GetOrgInfo(emailqueueto).Name);

            case "{orgmembercount}":
                return(GetOrgInfo(emailqueueto).Count);

            case "{paylink}":
                if (pi != null && pi.PayLink.HasValue())
                {
                    return("<a href=\"{0}\">Click this link to make a payment and view your balance.</a>".Fmt(pi.PayLink));
                }
                break;

            case "{peopleid}":
                return(p.PeopleId.ToString());

            case "{salutation}":
                if (emailqueueto != null)
                {
                    return(db.GoerSupporters.Where(ee => ee.Id == emailqueueto.GoerSupportId).Select(ee => ee.Salutation).SingleOrDefault());
                }
                break;

            case "{state}":
                return(p.PrimaryState);

            case "{toemail}":
                if (ListAddresses.Count > 0)
                {
                    return(ListAddresses[0].Address);
                }
                break;

            case "{today}":
                return(DateTime.Today.ToShortDateString());

            case "{title}":
                if (p.TitleCode.HasValue())
                {
                    return(p.TitleCode);
                }
                return(p.ComputeTitle());

            case "{track}":
                if (emailqueueto != null)
                {
                    return(emailqueueto.Guid.HasValue ? "<img src=\"{0}\" />".Fmt(db.ServerLink("/Track/Key/" + emailqueueto.Guid.Value.GuidToQuerystring())) : "");
                }
                break;

            case "{unsubscribe}":
                if (emailqueueto != null)
                {
                    return(UnSubscribeLink(emailqueueto));
                }
                break;

            default:
                if (emailqueueto == null)
                {
                    return(code);
                }

                if (code.StartsWith("{addsmallgroup:", StringComparison.OrdinalIgnoreCase))
                {
                    return(AddSmallGroup(code, emailqueueto));
                }

                if (code.StartsWith("{extra", StringComparison.OrdinalIgnoreCase))
                {
                    return(ExtraValue(code, emailqueueto));
                }

                if (registerLinkRe.IsMatch(code))
                {
                    return(RegisterLink(code, emailqueueto));
                }

                if (registerHrefRe.IsMatch(code))
                {
                    return(RegisterLinkHref(code, emailqueueto));
                }

                if (registerTagRe.IsMatch(code))
                {
                    return(RegisterTag(code, emailqueueto));
                }

                if (rsvpLinkRe.IsMatch(code))
                {
                    return(RsvpLink(code, emailqueueto));
                }

                if (sendLinkRe.IsMatch(code))
                {
                    return(SendLink(code, emailqueueto));
                }

                if (code.StartsWith("{orgextra:", StringComparison.OrdinalIgnoreCase))
                {
                    return(OrgExtra(code, emailqueueto));
                }

                if (code.StartsWith("{orgmember:", StringComparison.OrdinalIgnoreCase))
                {
                    return(OrgMember(code, emailqueueto));
                }

                if (code.StartsWith("{smallgroup:", StringComparison.OrdinalIgnoreCase))
                {
                    return(SmallGroup(code, emailqueueto));
                }

                if (code.StartsWith("{smallgroups", StringComparison.OrdinalIgnoreCase))
                {
                    return(SmallGroups(code, emailqueueto));
                }

                if (supportLinkRe.IsMatch(code))
                {
                    return(SupportLink(code, emailqueueto));
                }

                if (volReqLinkRe.IsMatch(code))
                {
                    return(VolReqLink(code, emailqueueto));
                }

                if (volSubLinkRe.IsMatch(code))
                {
                    return(VolSubLink(code, emailqueueto));
                }

                if (voteLinkRe.IsMatch(code))
                {
                    return(VoteLink(code, emailqueueto));
                }

                break;
            }

            return(code);
        }