Exemplo n.º 1
0
        public void EnrollAndConfirm()
        {
            if (masterorgid.HasValue)
            {
                EnrollAndConfirm2();
                return;
            }
            var Db = DbUtil.Db;
            var ti = Transaction;
            // make a list of email addresses
            var elist = new List <MailAddress>();

            if (UserPeopleId.HasValue)
            {
                if (user.SendEmailAddress1 ?? true)
                {
                    Util.AddGoodAddress(elist, user.FromEmail);
                }
                if (user.SendEmailAddress2 ?? false)
                {
                    Util.AddGoodAddress(elist, user.FromEmail2);
                }
            }
            if (registertag.HasValue())
            {
                var guid = registertag.ToGuid();
                var ot   = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                ot.Used = true;
            }
            var participants = new StringBuilder();

            for (var i = 0; i < List.Count; i++)
            {
                var p = List[i];
                if (p.IsNew)
                {
                    Person uperson = null;
                    switch (p.whatfamily)
                    {
                    case 1:
                        uperson = Db.LoadPersonById(UserPeopleId.Value);
                        break;

                    case 2:
                        if (i > 0)
                        {
                            uperson = List[i - 1].person;
                        }
                        break;
                    }
                    p.AddPerson(uperson, p.org.EntryPointId ?? 0);
                }

                Util.AddGoodAddress(elist, p.fromemail);
                participants.Append(p.ToString());
            }
            var p0 = List[0].person;

            if (this.user != null)
            {
                p0 = user;
            }

            //var emails = string.Join(",", elist.ToArray());
            string paylink = string.Empty;
            var    amtpaid = ti.Amt ?? 0;
            var    amtdue  = ti.Amtdue;

            var pids2 = new List <TransactionPerson>();

            foreach (var p in List)
            {
                if (p.PeopleId == null)
                {
                    return;
                }
                if (pids2.Any(pp => pp.PeopleId == p.PeopleId))
                {
                    continue;
                }
                pids2.Add(new TransactionPerson
                {
                    PeopleId = p.PeopleId.Value,
                    Amt      = p.TotalAmount(),
                    OrgId    = Orgid,
                });
            }

            ti.Emails          = Util.EmailAddressListToString(elist);
            ti.Participants    = participants.ToString();
            ti.TransactionDate = DateTime.Now;
            ti.OriginalTransaction.TransactionPeople.AddRange(pids2);

            if (org.IsMissionTrip == true)
            {
                paylink = Util.ResolveServerUrl("/OnlineReg/{0}?goerid={1}".Fmt(Orgid, p0.PeopleId));
            }
            else
            {
                var estr = HttpUtility.UrlEncode(Util.Encrypt(ti.OriginalId.ToString()));
                paylink = Util.ResolveServerUrl("/OnlineReg/PayAmtDue?q=" + estr);
            }

            var pids = pids2.Select(pp => pp.PeopleId);

            var details = new StringBuilder("<table>");

            for (var i = 0; i < List.Count; i++)
            {
                var p = List[i];

                var q = from pp in Db.People
                        where pids.Contains(pp.PeopleId)
                        where pp.PeopleId != p.PeopleId
                        select pp.Name;
                var others = string.Join(",", q.ToArray());

                var om = p.Enroll(ti, paylink, testing, others);
                details.AppendFormat(@"
<tr><td colspan='2'><hr/></td></tr>
<tr><th valign='top'>{0}</th><td>
{1}
</td></tr>", i + 1, p.PrepareSummaryText(ti));

                om.RegisterEmail = p.EmailAddress;
                om.TranId        = ti.OriginalId;
                int grouptojoin = p.setting.GroupToJoin.ToInt();
                if (grouptojoin > 0)
                {
                    OrganizationMember.InsertOrgMembers(Db, grouptojoin, p.PeopleId.Value, MemberTypeCode.Member, DateTime.Now, null, false);
                    DbUtil.Db.UpdateMainFellowship(grouptojoin);
                }

                OnlineRegPersonModel.CheckNotifyDiffEmails(p.person,
                                                           Db.StaffEmailForOrg(p.org.OrganizationId),
                                                           p.fromemail,
                                                           p.org.OrganizationName,
                                                           p.org.PhoneNumber);
                if (p.IsCreateAccount())
                {
                    p.CreateAccount();
                }
            }
            details.Append("\n</table>\n");
            Db.SubmitChanges();

            var DivisionName = org.DivisionName;

            var os           = settings[Orgid.Value];
            var EmailSubject = Util.PickFirst(os.Subject, "no subject");
            var EmailMessage = Util.PickFirst(os.Body, "no body");

            bool usedAdmins;
            var  NotifyIds = Db.StaffPeopleForOrg(org.OrganizationId, out usedAdmins);

            var Location = org.Location;

            var subject = Util.PickFirst(EmailSubject, "no subject");
            var message = Util.PickFirst(EmailMessage, "no message");

            message = CmsData.API.APIOrganization.MessageReplacements(DbUtil.Db, p0, DivisionName, org.OrganizationName, Location, message);
            subject = subject.Replace("{org}", org.OrganizationName);

            message = message.Replace("{phone}", org.PhoneNumber.FmtFone7());
            message = message.Replace("{tickets}", List[0].ntickets.ToString());
            message = message.Replace("{details}", details.ToString());
            message = message.Replace("{paid}", amtpaid.ToString("c"));
            message = message.Replace("{sessiontotal}", amtpaid.ToString("c"));
            message = message.Replace("{participants}", details.ToString());
            if (amtdue > 0)
            {
                message = message.Replace("{paylink}", "<a href='{0}'>Click this link to make a payment on your balance of {1:C}</a>.".Fmt(paylink, amtdue));
            }
            else
            {
                message = message.Replace("{paylink}", "You have a zero balance.");
            }

            var re = new Regex(@"\{donation(?<text>.*)donation\}", RegexOptions.Singleline | RegexOptions.Multiline);

            if (SupportMissionTrip && TotalAmount() > 0)
            {
                var p = List[0];
                ti.Fund = p.setting.DonationFund();
                var goerid = p.Parent.GoerId ?? p.MissionTripGoerId;
                if (goerid > 0 && p.MissionTripSupportGoer > 0)
                {
                    DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                        new GoerSenderAmount
                    {
                        Amount         = p.MissionTripSupportGoer.Value,
                        GoerId         = goerid,
                        Created        = DateTime.Now,
                        OrgId          = p.orgid.Value,
                        SupporterId    = p.PeopleId.Value,
                        NoNoticeToGoer = p.MissionTripNoNoticeToGoer,
                    });
                    if (p.Parent.GoerSupporterId.HasValue)
                    {
                        var gs = DbUtil.Db.GoerSupporters.Single(gg => gg.Id == p.Parent.GoerSupporterId);
                        if (!gs.SupporterId.HasValue)
                        {
                            gs.SupporterId = p.PeopleId;
                        }
                    }
                    if (!ti.TransactionId.StartsWith("Coupon"))
                    {
                        p.person.PostUnattendedContribution(DbUtil.Db,
                                                            p.MissionTripSupportGoer.Value, p.setting.DonationFundId,
                                                            "SupportMissionTrip: org={0}; goer={1}".Fmt(p.orgid, goerid), tranid: ti.Id);
                        // send notices
                        if (!p.MissionTripNoNoticeToGoer)
                        {
                            var goer = DbUtil.Db.LoadPersonById(goerid.Value);
                            Db.Email(NotifyIds[0].FromEmail, goer, org.OrganizationName + "-donation",
                                     "{0:C} donation received from {1}".Fmt(p.MissionTripSupportGoer.Value,
                                                                            Transaction.FullName(ti)));
                        }
                    }
                }
                if (p.MissionTripSupportGeneral > 0)
                {
                    DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                        new GoerSenderAmount
                    {
                        Amount      = p.MissionTripSupportGeneral.Value,
                        Created     = DateTime.Now,
                        OrgId       = p.orgid.Value,
                        SupporterId = p.PeopleId.Value
                    });
                    if (!ti.TransactionId.StartsWith("Coupon"))
                    {
                        p.person.PostUnattendedContribution(DbUtil.Db,
                                                            p.MissionTripSupportGeneral.Value, p.setting.DonationFundId,
                                                            "SupportMissionTrip: org={0}".Fmt(p.orgid), tranid: ti.Id);
                    }
                }
                var notifyids = Db.NotifyIds(org.OrganizationId, org.GiftNotifyIds);
                Db.Email(NotifyIds[0].FromEmail, notifyids, org.OrganizationName + "-donation",
                         "${0:N2} donation received from {1}".Fmt(ti.Amt, Transaction.FullName(ti)));

                var senderSubject = os.SenderSubject ?? "NO SUBJECT SET";
                var senderBody    = os.SenderBody ?? "NO SENDEREMAIL MESSAGE HAS BEEN SET";
                senderBody = CmsData.API.APIOrganization.MessageReplacements(DbUtil.Db, p.person, DivisionName, org.OrganizationName, Location, senderBody);
                senderBody = senderBody.Replace("{phone}", org.PhoneNumber.FmtFone7());
                senderBody = senderBody.Replace("{paid}", ti.Amt.ToString2("c"));

                ti.Description = "Mission Trip Giving";
                Db.Email(notifyids[0].FromEmail, p.person, elist, senderSubject, senderBody, false);
                Db.SubmitChanges();
                return;
            }

            if (!SupportMissionTrip && org != null && org.IsMissionTrip == true && ti.Amt > 0)
            {
                var p = List[0];
                ti.Fund = p.setting.DonationFund();

                DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                    new GoerSenderAmount
                {
                    Amount      = ti.Amt,
                    GoerId      = p.PeopleId,
                    Created     = DateTime.Now,
                    OrgId       = p.orgid.Value,
                    SupporterId = p.PeopleId.Value
                });
                if (!ti.TransactionId.StartsWith("Coupon"))
                {
                    p.person.PostUnattendedContribution(DbUtil.Db,
                                                        ti.Amt.Value, p.setting.DonationFundId,
                                                        "MissionTrip: org={0}; goer={1}".Fmt(p.orgid, p.PeopleId), tranid: ti.Id);
                    ti.Description = "Mission Trip Giving";
                }
            }
            else if (ti.Donate > 0)
            {
                var p = List[donor.Value];
                ti.Fund = p.setting.DonationFund();
                var desc = "{0}; {1}; {2}, {3} {4}".Fmt(
                    p.person.Name,
                    p.person.PrimaryAddress,
                    p.person.PrimaryCity,
                    p.person.PrimaryState,
                    p.person.PrimaryZip);
                if (!ti.TransactionId.StartsWith("Coupon"))
                {
                    p.person.PostUnattendedContribution(DbUtil.Db, ti.Donate.Value, p.setting.DonationFundId, desc, tranid: ti.Id);
                }
                var ma = re.Match(message);
                if (ma.Success)
                {
                    var v = ma.Groups["text"].Value;
                    message = re.Replace(message, v);
                }
                message = message.Replace("{donation}", ti.Donate.ToString2("N2"));
                // send donation confirmations
                Db.Email(NotifyIds[0].FromEmail, NotifyIds, subject + "-donation",
                         "${0:N2} donation received from {1}".Fmt(ti.Donate, Transaction.FullName(ti)));
            }
            else
            {
                message = re.Replace(message, "");
            }

            Db.CurrentOrgId = Orgid;
            // send confirmations
            if (subject != "DO NOT SEND")
            {
                Db.Email(NotifyIds[0].FromEmail, p0, elist,
                         subject, message, false);
            }

            Db.SubmitChanges();
            // notify the staff
            foreach (var p in List)
            {
                Db.Email(Util.PickFirst(p.person.FromEmail, NotifyIds[0].FromEmail), NotifyIds, Header,
                         @"{6}{0} has registered for {1}<br/>
Feepaid for this registrant: {2:C}<br/>
Total Fee for this registration: {3:C}<br/>
AmountDue: {4:C}<br/>
<pre>{5}</pre>".Fmt(p.person.Name,
                    Header,
                    amtpaid,
                    TotalAmount(),
                    amtdue,     // Amount Due
                    p.PrepareSummaryText(ti),
                    usedAdmins ? @"<span style='color:red'>THERE ARE NO NOTIFY IDS ON THIS REGISTRATION!!</span><br/>
<a href='http://docs.bvcms.com/OnlineRegistration/MessagesSettings.html'>see documentation</a><br/><br/>" : ""));
            }
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------------------------------------
        private void EnrollAndConfirm2()
        {
            var Db = DbUtil.Db;
            var ti = Transaction;

            for (var i = 0; i < List.Count; i++)
            {
                var p = List[i];
                if (p.IsNew)
                {
                    Person uperson = null;
                    switch (p.whatfamily)
                    {
                    case 1:
                        uperson = Db.LoadPersonById(UserPeopleId.Value);
                        break;

                    case 2:
                        if (i > 0)
                        {
                            uperson = List[i - 1].person;
                        }
                        break;
                    }
                    p.AddPerson(uperson, p.org.EntryPointId ?? 0);
                }
            }

            var amtpaid = ti.Amt ?? 0;

            var pids2 = new List <TransactionPerson>();

            foreach (var p in List)
            {
                if (p.PeopleId == null)
                {
                    return;
                }
                pids2.Add(new TransactionPerson
                {
                    PeopleId = p.PeopleId.Value,
                    Amt      = p.TotalAmount(),
                    OrgId    = p.orgid,
                });
            }

            ti.TransactionDate = DateTime.Now;
            var pids = pids2.Select(pp => pp.PeopleId);

            ti.OriginalTransaction.TransactionPeople.AddRange(pids2);

            for (var i = 0; i < List.Count; i++)
            {
                var p = List[i];

                var q = from pp in Db.People
                        where pids.Contains(pp.PeopleId)
                        where pp.PeopleId != p.PeopleId
                        select pp.Name;
                var others = string.Join(",", q.ToArray());

                var om = p.Enroll(ti, null, testing, others);
                om.RegisterEmail = p.EmailAddress;
                om.TranId        = ti.OriginalId;

                int grouptojoin = p.setting.GroupToJoin.ToInt();
                if (grouptojoin > 0)
                {
                    OrganizationMember.InsertOrgMembers(Db, grouptojoin, p.PeopleId.Value, MemberTypeCode.Member, DateTime.Now, null, false);
                }

                OnlineRegPersonModel.CheckNotifyDiffEmails(p.person,
                                                           Db.StaffEmailForOrg(p.org.OrganizationId),
                                                           p.fromemail,
                                                           p.org.OrganizationName,
                                                           p.org.PhoneNumber);
                if (p.CreatingAccount == true)
                {
                    p.CreateAccount();
                }

                string DivisionName     = masterorg.OrganizationName;
                string OrganizationName = p.org.OrganizationName;

                string emailSubject = null;
                string message      = null;

                if (p.setting.Body.HasValue())
                {
                    emailSubject = Util.PickFirst(p.setting.Subject, "no subject");
                    message      = p.setting.Body;
                }
                else
                {
                    try
                    {
                        if (masterorgid.HasValue && !settings.ContainsKey(masterorgid.Value))
                        {
                            ParseSettings();
                        }
                        var os = settings[masterorgid.Value];
                        emailSubject = Util.PickFirst(os.Subject, "no subject");
                        message      = Util.PickFirst(os.Body, "no body");
                    }
                    catch (Exception)
                    {
                        if (masterorgid == null)
                        {
                            throw new Exception("masterorgid was null");
                        }
                        if (settings == null)
                        {
                            throw new Exception("settings was null");
                        }
                        if (!settings.ContainsKey(masterorgid.Value))
                        {
                            throw new Exception("setting not found for masterorgid " + masterorgid.Value);
                        }
                        throw;
                    }
                }
                var NotifyIds = Db.StaffPeopleForOrg(p.org.OrganizationId);

                var notify = NotifyIds[0];

                string Location = p.org.Location;
                if (!Location.HasValue())
                {
                    Location = masterorg.Location;
                }

                message = CmsData.API.APIOrganization.MessageReplacements(DbUtil.Db, p.person, DivisionName, OrganizationName, Location, message);

                string details = p.PrepareSummaryText(ti);
                message         = message.Replace("{phone}", p.org.PhoneNumber.FmtFone7());
                message         = message.Replace("{tickets}", List[0].ntickets.ToString());
                message         = message.Replace("{details}", details);
                message         = message.Replace("{paid}", p.TotalAmount().ToString("c"));
                message         = message.Replace("{sessiontotal}", amtpaid.ToString("c"));
                message         = message.Replace("{participants}", details);
                Db.CurrentOrgId = p.orgid;

                // send confirmations
                if (emailSubject != "DO NOT SEND")
                {
                    Db.Email(notify.FromEmail, p.person, Util.EmailAddressListFromString(p.fromemail),
                             emailSubject, message, redacted: false);
                }
                // notify the staff
                Db.Email(Util.PickFirst(p.person.FromEmail, notify.FromEmail),
                         NotifyIds, Header,
                         @"{0} has registered for {1}<br/>
Feepaid for this registrant: {2:C}<br/>
Others in this registration session: {3:C}<br/>
Total Fee paid for this registration session: {4:C}<br/>
<pre>{5}</pre>".Fmt(p.person.Name,
                    Header,
                    p.AmountToPay(),
                    others,
                    amtpaid,
                    p.PrepareSummaryText(ti)));
            }
        }
Exemplo n.º 3
0
        public void EnrollAndConfirm()
        {
            if (masterorgid.HasValue)
            {
                EnrollAndConfirm2();
                return;
            }
            var Db = DbUtil.Db;
            var ti = Transaction;
            // make a list of email addresses
            var elist = new List <MailAddress>();

            if (UserPeopleId.HasValue)
            {
                if (user.SendEmailAddress1 ?? true)
                {
                    Util.AddGoodAddress(elist, user.FromEmail);
                }
                if (user.SendEmailAddress2 ?? false)
                {
                    Util.AddGoodAddress(elist, user.FromEmail2);
                }
            }
            if (registertag.HasValue())
            {
                var guid = registertag.ToGuid();
                var ot   = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                ot.Used = true;
            }
            var participants = new StringBuilder();

            for (var i = 0; i < List.Count; i++)
            {
                var p = List[i];
                if (p.IsNew)
                {
                    Person uperson = null;
                    switch (p.whatfamily)
                    {
                    case 1:
                        uperson = Db.LoadPersonById(UserPeopleId.Value);
                        break;

                    case 2:
                        if (i > 0)
                        {
                            uperson = List[i - 1].person;
                        }
                        break;
                    }
                    p.AddPerson(uperson, p.org.EntryPointId ?? 0);
                }

                Util.AddGoodAddress(elist, p.fromemail);
                participants.Append(p.ToString());
            }
            var p0 = List[0].person;

            if (this.user != null)
            {
                p0 = user;
            }

            //var emails = string.Join(",", elist.ToArray());
            string paylink = string.Empty;
            var    amtpaid = ti.Amt ?? 0;
            var    amtdue  = ti.Amtdue;

            var pids2 = new List <TransactionPerson>();

            foreach (var p in List)
            {
                if (p.PeopleId == null)
                {
                    return;
                }
                if (pids2.Any(pp => pp.PeopleId == p.PeopleId))
                {
                    continue;
                }
                pids2.Add(new TransactionPerson
                {
                    PeopleId = p.PeopleId.Value,
                    Amt      = p.TotalAmount(),
                    OrgId    = orgid,
                });
            }

            ti.Emails          = Util.EmailAddressListToString(elist);
            ti.Participants    = participants.ToString();
            ti.TransactionDate = DateTime.Now;
            ti.TransactionPeople.AddRange(pids2);

            var estr = HttpUtility.UrlEncode(Util.Encrypt(ti.Id.ToString()));

            paylink = Util.ResolveServerUrl("/OnlineReg/PayAmtDue?q=" + estr);

            var pids = pids2.Select(pp => pp.PeopleId);

            var details = new StringBuilder("<table>");

            for (var i = 0; i < List.Count; i++)
            {
                var p = List[i];

                var q = from pp in Db.People
                        where pids.Contains(pp.PeopleId)
                        where pp.PeopleId != p.PeopleId
                        select pp.Name;
                var others = string.Join(",", q.ToArray());

                others += "(Total due {0:c})".Fmt(amtdue);
                var om = p.Enroll(ti, paylink, testing, others);
                details.AppendFormat(@"
<tr><td colspan='2'><hr/></td></tr>
<tr><th valign='top'>{0}</th><td>
{1}
</td></tr>", i + 1, p.PrepareSummaryText(ti));

                om.RegisterEmail = p.email;
                om.TranId        = ti.Id;
                if (p.setting.GiveOrgMembAccess == true)
                {
                    if (p.person.Users.Count() == 0)
                    {
                        p.IsNew = false;
                        var u = p.CreateAccount();
                        if (u != null)
                        {
                            var list = u.Roles.ToList();
                            if (!list.Contains("Access"))
                            {
                                list.Add("Access");
                            }
                            if (!list.Contains("OrgMembersOnly"))
                            {
                                list.Add("OrgMembersOnly");
                            }
                            u.SetRoles(Db, list.ToArray(), false);
                        }
                    }
                    Db.SubmitChanges();
                }
                int grouptojoin = p.setting.GroupToJoin.ToInt();
                if (grouptojoin > 0)
                {
                    OrganizationMember.InsertOrgMembers(Db, grouptojoin, p.PeopleId.Value, 220, DateTime.Now, null, false);
                    DbUtil.Db.UpdateMainFellowship(grouptojoin);
                }

                OnlineRegPersonModel.CheckNotifyDiffEmails(p.person,
                                                           Db.StaffEmailForOrg(p.org.OrganizationId),
                                                           p.fromemail,
                                                           p.org.OrganizationName,
                                                           p.org.PhoneNumber);
                if (p.CreatingAccount == true && p.setting.GiveOrgMembAccess == false)
                {
                    p.CreateAccount();
                }
            }
            details.Append("\n</table>\n");
            Db.SubmitChanges();

            string DivisionName = null;

            if (masterorgid.HasValue)
            {
                DivisionName = masterorg.OrganizationName;
            }
            else if (div != null)
            {
                DivisionName = div.Name;
            }
            else if (org != null)
            {
                DivisionName = org.DivisionName;
            }

            string OrganizationName = null;

            if (org != null)
            {
                OrganizationName = org.OrganizationName;
            }
            else if (div != null)
            {
                OrganizationName = DivisionName;
            }

            if (!OrganizationName.HasValue())
            {
                OrganizationName = DivisionName;
            }

            string EmailSubject = null;
            string EmailMessage = null;

            if (org != null && settings[orgid.Value].Body.HasValue())
            {
                var os = settings[orgid.Value];
                EmailSubject = Util.PickFirst(os.Subject, "no subject");
                EmailMessage = Util.PickFirst(os.Body, "no body");
            }
            else if (masterorgid.HasValue && settings[masterorgid.Value].Body.HasValue())
            {
                var os = settings[masterorgid.Value];
                EmailSubject = Util.PickFirst(os.Subject, "no subject");
                EmailMessage = Util.PickFirst(os.Body, "no body");
            }
            else if (div != null)
            {
                EmailSubject = div.EmailSubject;
                EmailMessage = div.EmailMessage;
            }

            List <Person> NotifyIds = null;

            if (div != null)
            {
                NotifyIds = Db.StaffPeopleForDiv(div.Id);
            }
            else if (masterorgid.HasValue)
            {
                NotifyIds = Db.StaffPeopleForOrg(masterorg.OrganizationId);
            }
            else if (org != null)
            {
                NotifyIds = Db.StaffPeopleForOrg(org.OrganizationId);
            }
            var hasnotifyids = true;

            if (NotifyIds.Count() == 0)
            {
                NotifyIds    = Db.AdminPeople();
                hasnotifyids = false;
            }
            var notify = NotifyIds[0];

            string Location = null;

            if (div != null)
            {
                Location = List[0].org.Location;
            }
            else if (org != null)
            {
                Location = org.Location;
            }

            var subject = Util.PickFirst(EmailSubject, "no subject");
            var message = Util.PickFirst(EmailMessage, "no message");

            message = CmsData.API.APIOrganization.MessageReplacements(p0, DivisionName, OrganizationName, Location, message);
            subject = subject.Replace("{org}", org.OrganizationName);

            message = message.Replace("{phone}", org.PhoneNumber.FmtFone7());
            message = message.Replace("{tickets}", List[0].ntickets.ToString());
            message = message.Replace("{details}", details.ToString());
            message = message.Replace("{paid}", amtpaid.ToString("c"));
            message = message.Replace("{sessiontotal}", amtpaid.ToString("c"));
            message = message.Replace("{participants}", details.ToString());
            if (amtdue > 0)
            {
                message = message.Replace("{paylink}", "<a href='{0}'>Click this link to make a payment on your balance of {1:C}</a>.".Fmt(paylink, amtdue));
            }
            else
            {
                message = message.Replace("{paylink}", "You have a zero balance.");
            }

            var re = new Regex(@"\{donation(?<text>.*)donation\}", RegexOptions.Singleline | RegexOptions.Multiline);

            if (ti.Donate > 0)
            {
                var p = List[donor.Value];
                ti.Fund = p.setting.DonationFund();
                var desc = "{0}; {1}; {2}, {3} {4}".Fmt(
                    p.person.Name,
                    p.person.PrimaryAddress,
                    p.person.PrimaryCity,
                    p.person.PrimaryState,
                    p.person.PrimaryZip);
                p.person.PostUnattendedContribution(DbUtil.Db,
                                                    ti.Donate.Value,
                                                    p.setting.DonationFundId,
                                                    desc);
                var ma = re.Match(message);
                if (ma.Success)
                {
                    var v = ma.Groups["text"].Value;
                    message = re.Replace(message, v);
                }
                message = message.Replace("{donation}", ti.Donate.ToString2("N2"));
                // send donation confirmations
                Db.Email(notify.FromEmail, NotifyIds, subject + "-donation",
                         "${0:N2} donation received from {1}".Fmt(ti.Donate, ti.FullName));
            }
            else
            {
                message = re.Replace(message, "");
            }

            // send confirmations
            Db.Email(notify.FromEmail, p0, elist,
                     subject, message, false);
            // notify the staff
            foreach (var p in List)
            {
                var orgstaff = Db.StaffPeopleForOrg(p.org.OrganizationId);
                orgstaff.AddRange(NotifyIds);
                Db.Email(Util.PickFirst(p.person.FromEmail, notify.FromEmail),
                         orgstaff, Header,
                         @"{6}{0} has registered for {1}<br/>
Feepaid for this registrant: {2:C}<br/>
Total Fee for this registration: {3:C}<br/>
AmountDue: {4:C}<br/>
<pre>{5}</pre>".Fmt(p.person.Name,
                    Header,
                    amtpaid,
                    TotalAmount(),
                    amtdue, // Amount Due
                    p.PrepareSummaryText(ti),
                    hasnotifyids? "" : @"<span style='color:red'>THERE ARE NO NOTIFY IDS ON THIS REGISTRATION!!</span><br/>
<a href='http://www.bvcms.com/Doc/MessagesSettings'>see documentation</a><br/>"));
            }
        }