CmsWeb.Areas.OnlineReg.Models.OnlineRegModel.DoMissionTripSupporter C# (CSharp) Method

DoMissionTripSupporter() private method

private DoMissionTripSupporter ( ) : bool
return bool
        private bool DoMissionTripSupporter()
        {
            var notifyIds = GetNotifyIds();
            var p = List[0];
            Transaction.Fund = p.setting.DonationFund();
            var goerid = p.Parent.GoerId > 0
                ? p.Parent.GoerId
                : p.MissionTripGoerId;
            var forgoer = "";
            var forgeneral = "";
            if (p.MissionTripSupportGoer > 0 && p.orgid.HasValue && p.PeopleId.HasValue)
            {
                var gsa = new GoerSenderAmount
                {
                    Amount = p.MissionTripSupportGoer ?? 0,
                    Created = DateTime.Now,
                    OrgId = p.orgid.Value,
                    SupporterId = p.PeopleId.Value,
                    NoNoticeToGoer = p.MissionTripNoNoticeToGoer
                };
                if (goerid > 0)
                    gsa.GoerId = goerid;
                DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(gsa);
                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 (!Transaction.TransactionId.StartsWith("Coupon"))
                {
                    p.person.PostUnattendedContribution(DbUtil.Db,
                        p.MissionTripSupportGoer ?? 0, p.setting.DonationFundId,
                        $"SupportMissionTrip: org={p.orgid}; goer={goerid}", tranid: Transaction.Id);
                    Log("GoerSupport");
                    // send notices
                    if (goerid > 0 && !p.MissionTripNoNoticeToGoer)
                    {
                        var goer = DbUtil.Db.LoadPersonById(goerid.Value);
                        forgoer = $", {p.MissionTripSupportGoer:c} for {goer.Name}";
                        DbUtil.Db.Email(notifyIds[0].FromEmail, goer, org.OrganizationName + "-donation",
                            $"{p.MissionTripSupportGoer ?? 0:C} donation received from {Transaction.FullName(Transaction)}{forgoer}");
                    }
                }
            }
            if (p.MissionTripSupportGeneral > 0 && p.orgid.HasValue && p.PeopleId.HasValue)
            {
                DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                    new GoerSenderAmount
                    {
                        Amount = p.MissionTripSupportGeneral ?? 0,
                        Created = DateTime.Now,
                        OrgId = p.orgid.Value,
                        SupporterId = p.PeopleId.Value
                    });
                forgeneral = $", ({p.MissionTripSupportGeneral ?? 0:c}) for trip";
                if (!Transaction.TransactionId.StartsWith("Coupon"))
                {
                    p.person.PostUnattendedContribution(DbUtil.Db,
                        p.MissionTripSupportGeneral ?? 0, p.setting.DonationFundId,
                        "SupportMissionTrip: org=" + p.orgid, tranid: Transaction.Id);
                    Log("TripSupport");
                }
            }
            var notifyids = DbUtil.Db.NotifyIds(org.GiftNotifyIds);
            DbUtil.Db.Email(notifyIds[0].FromEmail, notifyids, org.OrganizationName + "-donation",
                $"${Transaction.Amt:N2} donation received from {Transaction.FullName(Transaction)}{forgoer}{forgeneral}");

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

            //Transaction.Description = "Mission Trip Giving";
            DbUtil.Db.Email(notifyids[0].FromEmail, p.person, listMailAddress, senderSubject, senderBody, false);
            DbUtil.Db.SubmitChanges();
            return true;
        }