Exemplo n.º 1
0
        private PaymentInfo PopulatePaymentInfo()
        {
            var pi = person.PaymentInfo();

            if (pi == null)
            {
                return(new PaymentInfo());
            }

            CreditCard           = pi.MaskedCard;
            Account              = pi.MaskedAccount;
            Expires              = pi.Expires;
            Routing              = Util.Mask(new StringBuilder(pi.Routing), 2);
            NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
            Type = pi.PreferredGivingType;
            if (NoCreditCardsAllowed)
            {
                Type = PaymentType.Ach; // bank account only
            }
            else if (NoEChecksAllowed)
            {
                Type = PaymentType.CreditCard; // credit card only
            }
            Type = NoEChecksAllowed ? PaymentType.CreditCard : Type;
            ClearMaskedNumbers(pi);
            total = FundItem.Sum(ff => ff.Value) ?? 0;

            return(pi);
        }
Exemplo n.º 2
0
 public decimal?FundItemValue(int n)
 {
     if (FundItem.ContainsKey(n))
     {
         return(FundItem[n]);
     }
     return(null);
 }
Exemplo n.º 3
0
 private void WriteFundItems(APIWriter w)
 {
     if (FundItem != null && FundItem.Count > 0)
     {
         foreach (var f in FundItem.Where(ff => ff.Value > 0))
         {
             w.Start("FundItem");
             w.Attr("fund", f.Key);
             w.AddText(f.Value.Value.ToString());
             w.End();
         }
     }
 }
Exemplo n.º 4
0
        private void ReadFundItem(XElement e)
        {
            if (FundItem == null)
            {
                FundItem = new Dictionary <int, decimal?>();
            }
            var fu = e.Attribute("fund");

            if (fu != null)
            {
                FundItem.Add(fu.Value.ToInt(), e.Value.ToDecimal());
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
0
        private void PopulateSetup(ManagedGiving rg)
        {
            RepeatPattern = rg.SemiEvery != "S" ? rg.Period : rg.SemiEvery;
            SemiEvery     = rg.SemiEvery;
            StartWhen     = rg.StartWhen;
            StopWhen      = null; //rg.StopWhen;
            Day1          = rg.Day1;
            Day2          = rg.Day2;
            EveryN        = rg.EveryN;
            Period        = rg.Period;
            foreach (var ra in person.RecurringAmounts.AsEnumerable())
            {
                FundItem.Add(ra.FundId, ra.Amt);
            }

            NextDate = rg.NextDate;
        }
Exemplo n.º 8
0
        public ManageGivingModel(int pid, int orgid = 0)
            : this()
        {
            this.pid   = pid;
            this.orgid = orgid;
            var rg = person.ManagedGiving();
            var pi = person.PaymentInfo();

            if (rg != null && pi != null)
            {
                SemiEvery = rg.SemiEvery;
                StartWhen = rg.StartWhen;
                StopWhen  = null; //rg.StopWhen;
                Day1      = rg.Day1;
                Day2      = rg.Day2;
                EveryN    = rg.EveryN;
                Period    = rg.Period;
                foreach (var ra in person.RecurringAmounts.AsEnumerable())
                {
                    FundItem.Add(ra.FundId, ra.Amt);
                }
                Cardnumber           = pi.MaskedCard;
                Account              = pi.MaskedAccount;
                Expires              = pi.Expires;
                Cardcode             = Util.Mask(new StringBuilder(pi.Ccv), 0);
                Routing              = Util.Mask(new StringBuilder(pi.Routing), 2);
                NextDate             = rg.NextDate;
                NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
                Type = pi.PreferredGivingType;
                if (NoCreditCardsAllowed)
                {
                    Type = "B"; // bank account only
                }
                else if (NoEChecksAllowed)
                {
                    Type = "C"; // credit card only
                }
                Type = NoEChecksAllowed ? "C" : Type;
            }
            else if (Setting.ExtraValueFeeName.HasValue())
            {
                var f = CmsWeb.Models.OnlineRegPersonModel.Funds().SingleOrDefault(ff => ff.Text == Setting.ExtraValueFeeName);
                // reasonable defaults
                Period    = "M";
                SemiEvery = "E";
                EveryN    = 1;
                var evamt = person.GetExtra(Setting.ExtraValueFeeName).ToDecimal();
                if (f != null && evamt > 0)
                {
                    FundItem.Add(f.Value.ToInt(), evamt);
                }
            }
            if (pi == null)
            {
                pi = new PaymentInfo();
            }
            FirstName = pi.FirstName ?? person.FirstName;
            Middle    = (pi.MiddleInitial ?? person.MiddleName).Truncate(1);
            LastName  = pi.LastName ?? person.LastName;
            Suffix    = pi.Suffix ?? person.SuffixCode;
            Address   = pi.Address ?? person.PrimaryAddress;
            City      = pi.City ?? person.PrimaryCity;
            State     = pi.State ?? person.PrimaryState;
            Zip       = pi.Zip ?? person.PrimaryZip;
            Phone     = pi.Phone ?? person.HomePhone ?? person.CellPhone;

            total = FundItem.Sum(ff => ff.Value) ?? 0;
        }
Exemplo n.º 9
0
        public void WriteXml(XmlWriter writer)
        {
            var optionsAdded   = false;
            var checkoxesAdded = false;
            var w = new APIWriter(writer);

            foreach (PropertyInfo pi in typeof(OnlineRegPersonModel).GetProperties(BindingFlags.Public | BindingFlags.Instance)
                     .Where(vv => vv.CanRead && vv.CanWrite))
            {
                switch (pi.Name)
                {
                case "FundItem":
                    if (FundItem != null && FundItem.Count > 0)
                    {
                        foreach (var f in FundItem.Where(ff => ff.Value > 0))
                        {
                            w.Start("FundItem");
                            w.Attr("fund", f.Key);
                            w.AddText(f.Value.Value.ToString());
                            w.End();
                        }
                    }
                    break;

                case "FamilyAttend":
                    if (FamilyAttend != null && FamilyAttend.Count > 0)
                    {
                        foreach (var f in FamilyAttend)
                        {
                            w.Start("FamilyAttend");
                            w.Attr("PeopleId", f.PeopleId);
                            w.Attr("Name", f.Name);
                            w.Attr("Attend", f.Attend);
                            w.Attr("Birthday", f.Birthday);
                            w.Attr("GenderId", f.GenderId);
                            w.Attr("MaritalId", f.MaritalId);
                            w.End();
                        }
                    }
                    break;

                case "ExtraQuestion":
                    if (ExtraQuestion != null)
                    {
                        for (var i = 0; i < ExtraQuestion.Count; i++)
                        {
                            if (ExtraQuestion[i] != null && ExtraQuestion[i].Count > 0)
                            {
                                foreach (var q in ExtraQuestion[i])
                                {
                                    w.Start("ExtraQuestion");
                                    w.Attr("set", i);
                                    w.Attr("question", q.Key);
                                    w.AddText(q.Value);
                                    w.End();
                                }
                            }
                        }
                    }
                    break;

                case "YesNoQuestion":
                    if (YesNoQuestion != null && YesNoQuestion.Count > 0)
                    {
                        foreach (var q in YesNoQuestion)
                        {
                            w.Start("YesNoQuestion");
                            w.Attr("question", q.Key);
                            w.AddText(q.Value.ToString());
                            w.End();
                        }
                    }
                    break;

                case "option":
                    if (option != null && option.Count > 0 && !optionsAdded)
                    {
                        foreach (var o in option)
                        {
                            w.Add("option", o);
                        }
                    }
                    optionsAdded = true;
                    break;

                case "Checkbox":
                    if (Checkbox != null && Checkbox.Count > 0 && !checkoxesAdded)
                    {
                        foreach (var c in Checkbox)
                        {
                            w.Add("Checkbox", c);
                        }
                    }
                    checkoxesAdded = true;
                    break;

                case "MenuItem":
                    if (MenuItem != null)
                    {
                        for (var i = 0; i < MenuItem.Count; i++)
                        {
                            if (MenuItem[i] != null && MenuItem[i].Count > 0)
                            {
                                foreach (var q in MenuItem[i])
                                {
                                    w.Start("MenuItem");
                                    w.Attr("set", i);
                                    w.Attr("name", q.Key);
                                    w.Attr("number", q.Value);
                                    w.End();
                                }
                            }
                        }
                    }
                    break;

                case "MissionTripPray":
                    if (Parent.SupportMissionTrip)
                    {
                        w.Add(pi.Name, MissionTripPray);
                    }
                    break;

                case "MissionTripGoerId":
                    if (Parent.SupportMissionTrip)
                    {
                        w.Add(pi.Name, MissionTripGoerId);
                    }
                    break;

                case "IsFilled":
                    if (IsFilled)
                    {
                        w.Add(pi.Name, IsFilled);
                    }
                    break;

                case "CreatingAccount":
                    if (CreatingAccount)
                    {
                        w.Add(pi.Name, CreatingAccount);
                    }
                    break;

                case "MissionTripNoNoticeToGoer":
                    if (MissionTripNoNoticeToGoer)
                    {
                        w.Add(pi.Name, MissionTripNoNoticeToGoer);
                    }
                    break;

                case "memberus":
                    if (memberus)
                    {
                        w.Add(pi.Name, memberus);
                    }
                    break;

                case "otherchurch":
                    if (otherchurch)
                    {
                        w.Add(pi.Name, otherchurch);
                    }
                    break;

                default:
                    w.Add(pi.Name, pi.GetValue(this, null));
                    break;
                }
            }
        }
Exemplo n.º 10
0
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);

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

            var eqset   = 0;
            var menuset = 0;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                case "FundItem":
                    if (FundItem == null)
                    {
                        FundItem = new Dictionary <int, decimal?>();
                    }
                    var fu = e.Attribute("fund");
                    if (fu != null)
                    {
                        FundItem.Add(fu.Value.ToInt(), e.Value.ToDecimal());
                    }
                    break;

                case "FamilyAttend":
                    var fa = new FamilyAttendInfo();
                    fa.PeopleId  = GetAttr(e, "PeopleId").ToInt2();
                    fa.Attend    = GetAttr(e, "Attend").ToBool();
                    fa.Name      = GetAttr(e, "Name");
                    fa.Birthday  = GetAttr(e, "Birthday");
                    fa.Email     = GetAttr(e, "Email");
                    fa.MaritalId = GetAttr(e, "MaritalId").ToInt2();
                    fa.GenderId  = GetAttr(e, "GenderId").ToInt2();
                    if (FamilyAttend == null)
                    {
                        FamilyAttend = new List <FamilyAttendInfo>();
                    }
                    FamilyAttend.Add(fa);
                    break;

                case "ExtraQuestion":
                    if (ExtraQuestion == null)
                    {
                        ExtraQuestion = new List <Dictionary <string, string> >();
                    }
                    var eqsetattr = e.Attribute("set");
                    if (eqsetattr != null)
                    {
                        eqset = eqsetattr.Value.ToInt();
                    }
                    if (ExtraQuestion.Count == eqset)
                    {
                        ExtraQuestion.Add(new Dictionary <string, string>());
                    }
                    var eq = e.Attribute("question");
                    if (eq != null)
                    {
                        ExtraQuestion[eqset].Add(eq.Value, e.Value);
                    }
                    break;

                case "YesNoQuestion":
                    if (YesNoQuestion == null)
                    {
                        YesNoQuestion = new Dictionary <string, bool?>();
                    }
                    var ynq = e.Attribute("question");
                    if (ynq != null)
                    {
                        YesNoQuestion.Add(ynq.Value, e.Value.ToBool());
                    }
                    break;

                case "option":
                    if (option == null)
                    {
                        option = new List <string>();
                    }
                    option.Add(e.Value);
                    break;

                case "Checkbox":
                    if (Checkbox == null)
                    {
                        Checkbox = new List <string>();
                    }
                    Checkbox.Add(e.Value);
                    break;

                case "MenuItem":
                    if (MenuItem == null)
                    {
                        MenuItem = new List <Dictionary <string, int?> >();
                    }
                    var menusetattr = e.Attribute("set");
                    if (menusetattr != null)
                    {
                        menuset = menusetattr.Value.ToInt();
                    }
                    if (MenuItem.Count == menuset)
                    {
                        MenuItem.Add(new Dictionary <string, int?>());
                    }
                    var aname  = e.Attribute("name");
                    var number = e.Attribute("number");
                    if (aname != null && number != null)
                    {
                        MenuItem[menuset].Add(aname.Value, number.Value.ToInt());
                    }
                    break;

                case "MissionTripPray":
                    MissionTripPray = e.Value.ToBool();
                    break;

                case "MissionTripGoerId":
                    MissionTripGoerId = e.Value.ToInt();
                    break;

                case "CreatingAccount":
                    CreatingAccount = e.Value.ToBool();
                    break;

                default:
                    Util.SetPropertyFromText(this, TranslateName(name), e.Value);
                    break;
                }
            }
        }
Exemplo n.º 11
0
        public void WriteXml(XmlWriter writer)
        {
            var optionsAdded   = false;
            var checkoxesAdded = false;
            var menuitemsAdded = false;
            var w = new APIWriter(writer);

            foreach (PropertyInfo pi in typeof(OnlineRegPersonModel).GetProperties(BindingFlags.Public | BindingFlags.Instance)
                     .Where(vv => vv.CanRead && vv.CanWrite))
            {
                switch (pi.Name)
                {
                case "FundItem":
                    if (FundItem != null && FundItem.Count > 0)
                    {
                        foreach (var f in FundItem.Where(ff => ff.Value > 0))
                        {
                            w.Start("FundItem");
                            w.Attr("fund", f.Key);
                            w.AddText(f.Value.Value.ToString());
                            w.End();
                        }
                    }
                    break;

                case "ExtraQuestion":
                    if (ExtraQuestion != null)
                    {
                        for (var i = 0; i < ExtraQuestion.Count; i++)
                        {
                            if (ExtraQuestion[i] != null && ExtraQuestion[i].Count > 0)
                            {
                                foreach (var q in ExtraQuestion[i])
                                {
                                    w.Start("ExtraQuestion");
                                    w.Attr("set", i);
                                    w.Attr("question", q.Key);
                                    w.AddText(q.Value);
                                    w.End();
                                }
                            }
                        }
                    }
                    break;

                case "YesNoQuestion":
                    if (YesNoQuestion != null && YesNoQuestion.Count > 0)
                    {
                        foreach (var q in YesNoQuestion)
                        {
                            w.Start("YesNoQuestion");
                            w.Attr("question", q.Key);
                            w.AddText(q.Value.ToString());
                            w.End();
                        }
                    }
                    break;

                case "option":
                    if (option != null && option.Count > 0 && !optionsAdded)
                    {
                        foreach (var o in option)
                        {
                            w.Add("option", o);
                        }
                    }
                    optionsAdded = true;
                    break;

                case "Checkbox":
                    if (Checkbox != null && Checkbox.Count > 0 && !checkoxesAdded)
                    {
                        foreach (var c in Checkbox)
                        {
                            w.Add("Checkbox", c);
                        }
                    }
                    checkoxesAdded = true;
                    break;

                case "MenuItem":
                    if (MenuItem != null && !menuitemsAdded)
                    {
                        foreach (var kv in MenuItem)
                        {
                            w.Start("MenuItem");
                            w.Attr("name", kv.Key);
                            w.Attr("number", kv.Value);
                            w.End();
                        }
                    }
                    menuitemsAdded = true;
                    break;

                default:
                    w.Add(pi.Name, pi.GetValue(this, null));
                    break;
                }
            }
        }
Exemplo n.º 12
0
        public void ReadXml(XmlReader reader)
        {
            var s = reader.ReadOuterXml();
            var x = XDocument.Parse(s);

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

            var eqset = 0;

            foreach (var e in x.Root.Elements())
            {
                var name = e.Name.ToString();
                switch (name)
                {
                case "FundItem":
                    if (FundItem == null)
                    {
                        FundItem = new Dictionary <int, decimal?>();
                    }
                    var fu = e.Attribute("fund");
                    if (fu != null)
                    {
                        FundItem.Add(fu.Value.ToInt(), e.Value.ToDecimal());
                    }
                    break;

                case "ExtraQuestion":
                    if (ExtraQuestion == null)
                    {
                        ExtraQuestion = new List <Dictionary <string, string> >();
                    }
                    var eqsetattr = e.Attribute("set");
                    if (eqsetattr != null)
                    {
                        eqset = eqsetattr.Value.ToInt();
                    }
                    if (ExtraQuestion.Count == eqset)
                    {
                        ExtraQuestion.Add(new Dictionary <string, string>());
                    }
                    var eq = e.Attribute("question");
                    if (eq != null)
                    {
                        ExtraQuestion[eqset].Add(eq.Value, e.Value);
                    }
                    break;

                case "YesNoQuestion":
                    if (YesNoQuestion == null)
                    {
                        YesNoQuestion = new Dictionary <string, bool?>();
                    }
                    var ynq = e.Attribute("question");
                    if (ynq != null)
                    {
                        YesNoQuestion.Add(ynq.Value, e.Value.ToBool());
                    }
                    break;

                case "option":
                    if (option == null)
                    {
                        option = new List <string>();
                    }
                    option.Add(e.Value);
                    break;

                case "Checkbox":
                    if (Checkbox == null)
                    {
                        Checkbox = new List <string>();
                    }
                    Checkbox.Add(e.Value);
                    break;

                case "MenuItem":
                    if (MenuItem == null)
                    {
                        MenuItem = new Dictionary <string, int?>();
                    }
                    var aname  = e.Attribute("name");
                    var number = e.Attribute("number");
                    if (aname != null && number != null)
                    {
                        MenuItem.Add(aname.Value, number.Value.ToInt());
                    }
                    break;

                default:
                    Util.SetPropertyFromText(this, name, e.Value);
                    break;
                }
            }
        }