Пример #1
0
        private void PopulateDefaultFundIds(string defaultFundIds, Person person)
        {
            if (string.IsNullOrWhiteSpace(defaultFundIds) && person.CampusId.HasValue)
            {
                // look up campus default fund mapping if present.
                var setting = $"DefaultCampusFunds-{person.CampusId}";
                var db      = DbUtil.DbReadOnly;
                defaultFundIds = db.Setting(setting, string.Empty);
            }

            if (!string.IsNullOrWhiteSpace(defaultFundIds))
            {
                var list = defaultFundIds.Split(',');
                DefaultFundIds.AddRange(list);
            }

            if (DefaultFundIds.Any())
            {
                FirstDefaultFundName = OnlineRegPersonModel.GetFundName(DefaultFundIds.First().ToInt());
            }

            var fundList = OnlineRegPersonModel.FundList();

            FallbackDefaultFundIds.AddRange(fundList.Where(f => !DefaultFundIds.Contains(f.Value)).Select(f => f.Value));
        }
Пример #2
0
        public OnlineRegPersonModel LoadExistingPerson(int id, int index)
        {
            var person = CurrentDatabase.LoadPersonById(id);
            var p      = new OnlineRegPersonModel(CurrentDatabase)
            {
                Campus             = person.CampusId.GetValueOrDefault().ToString(),
                DateOfBirth        = person.DOB,
                EmailAddress       = person.EmailAddress.HasValue() ? person.EmailAddress : user.EmailAddress,
                FirstName          = person.PreferredName,
                LastName           = person.LastName,
                PeopleId           = id,
                Phone              = Util.PickFirst(person.CellPhone, person.HomePhone),
                orgid              = Orgid,
                masterorgid        = masterorgid,
                IsFamily           = true,
                Found              = true,
                IsValidForExisting = true,
            };

            if (p.LoggedIn && org != null)
            {
                var setting = settings[org.OrganizationId];
                if (setting.AllowReRegister)
                {
                    var om = org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == id);
                    if (om != null)
                    {
                        p.RepopulateRegistration(om);
                    }
                }
            }
            return(p);
        }
Пример #3
0
 private List <Person> GetNotifyIds(OnlineRegPersonModel p)
 {
     if (_notifyIds != null)
     {
         return(_notifyIds);
     }
     return(_notifyIds = DbUtil.Db.StaffPeopleForOrg(p.org.OrganizationId, out UsedAdminsForNotify));
 }
Пример #4
0
        private string GetSubject(OnlineRegPersonModel p)
        {
            if (p.setting.Subject.HasValue())
            {
                return(Util.PickFirst(p.setting.Subject, defaultSubject));
            }
            var os = GetMasterOrgSettings();

            return(Util.PickFirst(os.Subject, defaultSubject));
        }
Пример #5
0
        private void SendSingleConfirmationForOrg(OnlineRegPersonModel p)
        {
            var ts = TransactionSummary();

            DbUtil.Db.SetCurrentOrgId(p.orgid);
            var emailSubject = GetSubject(p);
            var message      = p.GetMessage();
            var details      = "";

            if (message.Contains("{details}"))
            {
                details = p.PrepareSummaryText(DbUtil.Db);
                message = message.Replace("{details}", details);
            }
            var notifyIds = DbUtil.Db.StaffPeopleForOrg(p.org.OrganizationId);
            var notify    = notifyIds[0];

            var location = p.org.Location;

            if (!location.HasValue())
            {
                location = masterorg.Location;
            }

            message = APIOrganization.MessageReplacements(DbUtil.Db, p.person,
                                                          masterorg.OrganizationName, p.org.OrganizationId, p.org.OrganizationName, location, message);

            if (Transaction.Donate > 0 && p == List[donor ?? 0])
            {
                message = DoDonationModifyMessage(message);
            }
            else
            {
                message = donationtext.Replace(message, "");
            }

            // send confirmations
            if (emailSubject != "DO NOT SEND")
            {
                DbUtil.Db.Email(notify.FromEmail, p.person, Util.EmailAddressListFromString(p.fromemail),
                                emailSubject, message, false);
                Log("SentConfirmation");
            }
            // notify the staff
            DbUtil.Db.Email(Util.PickFirst(p.person.FromEmail, notify.FromEmail),
                            notifyIds, Header,
                            $@"{p.person.Name} has registered for {Header}<br/>
Feepaid for this registrant: {p.AmountToPay():C}<br/>
Others in this registration session: {p.GetOthersInTransaction(Transaction)}<br/>
Total Fee paid for this registration session: {ts?.TotPaid:C}<br/>
<pre>{details}</pre>");
        }
Пример #6
0
        private void PopulateExtraValueDefaults()
        {
            var f = OnlineRegPersonModel.FullFundList().SingleOrDefault(ff => ff.Text == Setting.ExtraValueFeeName);

            PopulateReasonableDefaults();

            var evamt = person.GetExtra(Setting.ExtraValueFeeName).ToDecimal();

            if (f != null && evamt > 0)
            {
                FundItem.Add(f.Value.ToInt(), evamt);
            }
        }
Пример #7
0
        // Make sure that we only use the 5 find fields and no previous data from a previous find attempt
        public OnlineRegPersonModel GetFreshFindInfo(int id)
        {
            var p = List[id];

            List[id] = new OnlineRegPersonModel(CurrentDatabase)
            {
                FirstName    = p.FirstName,
                LastName     = p.LastName,
                DateOfBirth  = p.DateOfBirth,
                Phone        = p.Phone,
                EmailAddress = p.EmailAddress,
                orgid        = Orgid,
                masterorgid  = masterorgid,
            };
            return(List[id]);
        }
Пример #8
0
        private void PopulateReasonableDefaults()
        {
            var f = OnlineRegPersonModel.FullFundList().SingleOrDefault(ff => ff.Text == Setting.ExtraValueFeeName);

            // reasonable defaults
            RepeatPattern = "M";
            Period        = "M";
            SemiEvery     = "E";
            EveryN        = 1;
            var evamt = person.GetExtra(Setting.ExtraValueFeeName).ToDecimal();

            if (f != null && evamt > 0)
            {
                FundItem.Add(f.Value.ToInt(), evamt);
            }
        }
Пример #9
0
        public IEnumerable <FundItemChosen> FundItemsChosen()
        {
            if (FundItem == null)
            {
                return(new List <FundItemChosen>());
            }
            var items = OnlineRegPersonModel.FullFundList();
            var q     = from i in FundItem
                        join m in items on i.Key equals m.Value.ToInt()
                            where i.Value.HasValue
                        select new FundItemChosen
            {
                fundid = m.Value.ToInt(), desc = m.Text, amt = i.Value.Value
            };

            return(q);
        }
Пример #10
0
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);

            if (x.Root == null)
            {
                return;
            }

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                case "List":
                    foreach (var ee in e.Elements())
                    {
                        OnlineRegPersonModel personModel = Util.DeSerialize <OnlineRegPersonModel>(ee.ToString());
                        personModel.CurrentDatabase = CurrentDatabase;
                        List.Add(personModel);
                    }
                    break;

                case "History":
                    foreach (var ee in e.Elements())
                    {
                        _history.Add(ee.Value);
                    }
                    break;

                default:
                    Util.SetPropertyFromText(this, name, e.Value);
                    break;
                }
            }
        }
Пример #11
0
        private OrganizationMember RecordAllFamilyAttends(OrganizationMember om)
        {
            om.AddToGroup(DbUtil.Db, "Attending");
            om.AddToGroup(DbUtil.Db, "Registered");
            foreach (var fm in FamilyAttend)
            {
                if (fm.PeopleId == -1)
                {
                    continue;
                }

                Person             pp  = null;
                OrganizationMember omm = null;
                if (!fm.PeopleId.HasValue && fm.Attend)
                {
                    if (!fm.Name.HasValue())
                    {
                        continue;
                    }

                    string first, last;
                    Util.NameSplit(fm.Name, out first, out last);
                    if (!first.HasValue())
                    {
                        first = last;
                        last  = LastName;
                    }
                    var uperson = DbUtil.Db.LoadPersonById(PeopleId ?? 0);
                    var p       = new OnlineRegPersonModel()
                    {
                        FirstName    = first,
                        LastName     = last,
                        DateOfBirth  = fm.Birthday,
                        EmailAddress = fm.Email,
                        gender       = fm.GenderId,
                        married      = fm.MaritalId
                    };
                    p.AddPerson(uperson, org.EntryPointId ?? 0);
                    pp  = p.person;
                    omm = OrganizationMember.InsertOrgMembers(DbUtil.Db, org.OrganizationId, pp.PeopleId,
                                                              MemberTypeCode.Member, DateTime.Now, null, false);
                }
                else
                {
                    pp = DbUtil.Db.LoadPersonById(fm.PeopleId ?? 0);
                    if (fm.Attend)
                    {
                        omm = OrganizationMember.InsertOrgMembers(DbUtil.Db, org.OrganizationId, pp.PeopleId,
                                                                  MemberTypeCode.Member, DateTime.Now, null, false);
                    }
                    else
                    {
                        omm = OrganizationMember.Load(DbUtil.Db, pp.PeopleId, org.OrganizationId);
                        omm?.RemoveFromGroup(DbUtil.Db, "Attending");
                    }
                }
                if (omm == null)
                {
                    continue;
                }

                if (fm.Attend)
                {
                    omm.AddToGroup(DbUtil.Db, "Attending");
                }

                if (!fm.PeopleId.HasValue)
                {
                    omm.AddToGroup(DbUtil.Db, "Added");
                }
            }
            return(om);
        }
Пример #12
0
 private string GetSubject(OnlineRegPersonModel p)
 {
     if (p.setting.Subject.HasValue())
         return Util.PickFirst(p.setting.Subject, defaultSubject);
     var os = GetMasterOrgSettings();
     return Util.PickFirst(os.Subject, defaultSubject);
 }
Пример #13
0
 private List<Person> GetNotifyIds(OnlineRegPersonModel p)
 {
     if (_notifyIds != null)
         return _notifyIds;
     return _notifyIds = DbUtil.Db.StaffPeopleForOrg(p.org.OrganizationId, out UsedAdminsForNotify);
 }
Пример #14
0
 // Make sure that we only use the 5 find fields and no previous data from a previous find attempt
 public OnlineRegPersonModel GetFreshFindInfo(int id)
 {
     var p = List[id]; 
     List[id] = new OnlineRegPersonModel
     {
         FirstName = p.FirstName,
         LastName = p.LastName,
         DateOfBirth = p.DateOfBirth,
         Phone = p.Phone,
         EmailAddress = p.EmailAddress,
         orgid = Orgid,
         masterorgid = masterorgid,
     };
     return List[id];
 }
Пример #15
0
 public OnlineRegPersonModel LoadExistingPerson(int id, int index)
 {
     var person = DbUtil.Db.LoadPersonById(id);
     var p = new OnlineRegPersonModel
     {
         DateOfBirth = person.DOB,
         EmailAddress = person.EmailAddress.HasValue() ? person.EmailAddress : user.EmailAddress,
         FirstName = person.PreferredName,
         LastName = person.LastName,
         PeopleId = id,
         Phone = Util.PickFirst(person.CellPhone, person.HomePhone),
         orgid = Orgid,
         masterorgid = masterorgid,
         IsFamily = true,
         Found = true,
         IsValidForExisting = true,
     };
     if (p.LoggedIn && org != null)
     {
         var setting = settings[org.OrganizationId];
         if (setting.AllowReRegister)
         {
             var om = org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == id);
             if (om != null)
                 p.RepopulateRegistration(om);
         }
     }
     return p;
 }
Пример #16
0
 private string GetMessage(OnlineRegPersonModel p)
 {
     if (p.setting.Body.HasValue())
         return p.setting.Body;
     var os = GetMasterOrgSettings();
     return Util.PickFirst(os.Body, "no body");
 }
Пример #17
0
        private void SendSingleConfirmationForOrg(OnlineRegPersonModel p)
        {
            var ts = TransactionSummary();
            DbUtil.Db.SetCurrentOrgId(p.orgid);
            var emailSubject = GetSubject(p);
            var details = p.PrepareSummaryText();
            var message = p.GetMessage(details);

            var NotifyIds = DbUtil.Db.StaffPeopleForOrg(p.org.OrganizationId);
            var notify = NotifyIds[0];

            var location = p.org.Location;
            if (!location.HasValue())
                location = masterorg.Location;

            message = APIOrganization.MessageReplacements(DbUtil.Db, p.person,
                masterorg.OrganizationName, p.org.OrganizationId, p.org.OrganizationName, location, message);

            if (Transaction.Donate > 0 && p == List[donor ?? 0])
                message = DoDonationModifyMessage(message);
            else
                message = donationtext.Replace(message, "");

            // send confirmations
            if (emailSubject != "DO NOT SEND")
            {
                DbUtil.Db.Email(notify.FromEmail, p.person, Util.EmailAddressListFromString(p.fromemail),
                    emailSubject, message, false);
                Log("SentConfirmation");
            }
            // notify the staff
            DbUtil.Db.Email(Util.PickFirst(p.person.FromEmail, notify.FromEmail),
                NotifyIds, Header,
                $@"{p.person.Name} has registered for {Header}<br/>
            Feepaid for this registrant: {p.AmountToPay():C}<br/>
            Others in this registration session: {p.GetOthersInTransaction(Transaction)}<br/>
            Total Fee paid for this registration session: {ts?.TotPaid:C}<br/>
            <pre>{p.PrepareSummaryText()}</pre>");
        }
Пример #18
0
        private string GetSubject(OnlineRegPersonModel p)
        {
            var os = GetMasterOrgSettings();

            return(Util.PickFirst(p.setting?.Subject, os?.Subject, defaultSubject));
        }
Пример #19
0
 private OrganizationMember RecordAllFamilyAttends(OrganizationMember om)
 {
     om.AddToGroup(DbUtil.Db, "Attended");
     om.AddToGroup(DbUtil.Db, "Registered");
     foreach (var fm in FamilyAttend)
     {
         if (fm.PeopleId == -1)
             continue;
         Person pp = null;
         OrganizationMember omm = null;
         if (!fm.PeopleId.HasValue && fm.Attend)
         {
             if (!fm.Name.HasValue())
                 continue;
             string first, last;
             Util.NameSplit(fm.Name, out first, out last);
             if (!first.HasValue())
             {
                 first = last;
                 last = LastName;
             }
             var uperson = DbUtil.Db.LoadPersonById(PeopleId ?? 0);
             var p = new OnlineRegPersonModel()
             {
                 FirstName = first,
                 LastName = last,
                 DateOfBirth = fm.Birthday,
                 EmailAddress = fm.Email,
                 gender = fm.GenderId,
                 married = fm.MaritalId
             };
             p.AddPerson(uperson, org.EntryPointId ?? 0);
             pp = p.person;
             omm = OrganizationMember.InsertOrgMembers(DbUtil.Db, org.OrganizationId, pp.PeopleId,
                 MemberTypeCode.Member, DateTime.Now, null, false);
         }
         else
         {
             pp = DbUtil.Db.LoadPersonById(fm.PeopleId ?? 0);
             if (fm.Attend)
                 omm = OrganizationMember.InsertOrgMembers(DbUtil.Db, org.OrganizationId, pp.PeopleId,
                     MemberTypeCode.Member, DateTime.Now, null, false);
             else
             {
                 omm = OrganizationMember.Load(DbUtil.Db, pp.PeopleId, org.OrganizationId);
                 omm?.RemoveFromGroup(DbUtil.Db, "Attended");
             }
         }
         if (omm == null)
             continue;
         if (fm.Attend)
             omm.AddToGroup(DbUtil.Db, "Attended");
         if (!fm.PeopleId.HasValue)
             omm.AddToGroup(DbUtil.Db, "Added");
     }
     return om;
 }
Пример #20
0
        public OnlineRegModel(HttpRequestBase req, CMSDataContext db, int?id, bool?testing, string email, bool?login, string source)
            : this()
        {
            CurrentDatabase = db;
            Orgid           = id;
            if (req?.Url != null)
            {
                URL = req.Url.ToString();
            }

            if (CurrentDatabase.Roles.Any(rr => rr.RoleName == "disabled"))
            {
                throw new Exception("Site is disabled for maintenance, check back later");
            }

            if (!id.HasValue)
            {
                throw new BadRegistrationException("no organization");
            }

            MobileAppMenuController.Source = source;

            if (org == null && masterorg == null)
            {
                throw new BadRegistrationException("invalid registration");
            }

            if (masterorg != null)
            {
                if (!UserSelectClasses(masterorg).Any())
                {
                    throw new Exception("no classes available on this org");
                }
            }
            else if (org != null)
            {
                if ((org.RegistrationTypeId ?? 0) == RegistrationTypeCode.None)
                {
                    throw new BadRegistrationException("no registration allowed on this org");
                }
            }
            this.testing = testing == true || DbUtil.Db.Setting("OnlineRegTesting", Util.IsDebug() ? "true" : "false").ToBool();

            // the email passed in is valid or they did not specify login
            if (AllowAnonymous && (Util.ValidEmail(email) || login != true))
            {
                nologin = true;
            }

            if (nologin)
            {
                CreateAnonymousList();
            }
            else
            {
                List = new List <OnlineRegPersonModel>();
            }

            // if logged in and trying a non anonymous online reg, use email for logged in user
            if (!AllowAnonymous && !email.HasValue() && Util.UserEmail.HasValue())
            {
                email       = Util.UserEmail;
                ProcessType = PaymentProcessTypes.OnlineRegistration;
            }

            // prepopulate their email address they passed in
            if (Util.ValidEmail(email) && ProcessType == PaymentProcessTypes.OnlineRegistration)
            {
                var person =
                    new OnlineRegPersonModel
                {
                    orgid        = Orgid,
                    masterorgid  = masterorgid,
                    EmailAddress = email
                };
                List.Add(person);
            }

            HistoryAdd("index");
            UpdateDatum();
        }