Exemplo n.º 1
0
 private void SetHeaders(OnlineRegModel m2)
 {
     ViewBag.Url = m2.URL;
     Session["gobackurl"] = m2.URL;
     ViewBag.timeout = INT_timeout;
     SetHeaders(m2.orgid ?? m2.masterorgid ?? 0);
 }
Exemplo n.º 2
0
 public ActionResult AddAnotherPerson(OnlineRegModel m)
 {
     m.History.Add("AddAnotherPerson");
     m.ParseSettings();
     if (!ModelState.IsValid)
         return FlowList(m, "AddAnotherPerson");
     #if DEBUG2
     m.List.Add(new OnlineRegPersonModel
     {
         divid = m.divid,
         orgid = m.orgid,
         masterorgid = m.masterorgid,
         first = "Bethany",
         last = "Carroll",
         //bmon = 1,
         //bday = 29,
         //byear = 1987,
         dob = "1/29/87",
         email = "*****@*****.**",
         phone = "9017581862".FmtFone(),
         LoggedIn = m.UserPeopleId.HasValue,
     });
     #else
     m.List.Add(new OnlineRegPersonModel
     {
         orgid = m.orgid,
         masterorgid = m.masterorgid,
         LoggedIn = m.UserPeopleId.HasValue,
     });
     #endif
     return FlowList(m, "AddAnotherPerson");
 }
Exemplo n.º 3
0
 private void SetHeaders(OnlineRegModel m2)
 {
     ViewBag.Url = m2.URL;
     Session["gobackurl"] = m2.URL;
     if(m2.UseBootstrap)
         SetHeaders2(m2.Orgid ?? m2.masterorgid ?? 0);
     else
         SetHeaders(m2.Orgid ?? m2.masterorgid ?? 0);
 }
Exemplo n.º 4
0
 public ActionResult AskDonation(OnlineRegModel m)
 {
     m.History.Add("AskDonation");
     if (m.List.Count == 0)
         return Content("Can't find any registrants");
     RemmoveLastRegistrantIfEmpty(m);
     SetHeaders(m);
     return View(m);
 }
Exemplo n.º 5
0
        public void UpdateSubscriptions()
        {
            var q = from o in OnlineRegModel.UserSelectClasses(masterorg)
                    let om = o.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == pid)
                             where om != null
                             select om;
            var current = q.ToList();

            if (Subscribe == null)
            {
                Subscribe = new int[] { }
            }
            ;

            var drops = from om in current
                        join id in Subscribe on om.OrganizationId equals id into j
                        from id in j.DefaultIfEmpty()
                        where id == 0
                        select om;

            var joins = from id in Subscribe
                        join om in current on id equals om.OrganizationId into j
                        from om in j.DefaultIfEmpty()
                        where om == null
                        select id;

            foreach (var om in drops)
            {
                om.Drop(DbUtil.Db, addToHistory: true);
                DbUtil.Db.SubmitChanges();
            }
            foreach (var id in joins)
            {
                OrganizationMember.InsertOrgMembers(DbUtil.Db,
                                                    id, pid, MemberTypeCode.Member, DateTime.Now, null, false);
                DbUtil.Db.SubmitChanges();
                //DbUtil.Db.UpdateMainFellowship(id);
            }
        }
Exemplo n.º 6
0
        public static Transaction CreateTransaction(CMSDataContext Db, Transaction t, decimal?amount)
        {
            var amtdue = t.Amtdue != null ? t.Amtdue - (amount ?? 0) : null;
            var ti     = new Transaction
            {
                Name               = t.Name,
                First              = t.First,
                MiddleInitial      = t.MiddleInitial,
                Last               = t.Last,
                Suffix             = t.Suffix,
                Donate             = t.Donate,
                Amtdue             = amtdue,
                Amt                = amount,
                Emails             = Util.FirstAddress(t.Emails).Address,
                Testing            = t.Testing,
                Description        = t.Description,
                OrgId              = t.OrgId,
                Url                = t.Url,
                Address            = t.Address,
                TransactionGateway = OnlineRegModel.GetTransactionGateway(),
                City               = t.City,
                State              = t.State,
                Zip                = t.Zip,
                DatumId            = t.DatumId,
                Phone              = t.Phone,
                OriginalId         = t.OriginalId ?? t.Id,
                Financeonly        = t.Financeonly,
                TransactionDate    = DateTime.Now,
                PaymentType        = t.PaymentType,
                LastFourCC         = t.LastFourCC,
                LastFourACH        = t.LastFourACH
            };

            Db.Transactions.InsertOnSubmit(ti);
            Db.SubmitChanges();
            return(ti);
        }
Exemplo n.º 7
0
        public ActionResult Index(int? id, bool? testing, string email, bool? nologin, bool? login, string registertag, bool? showfamily, int? goerid, int? gsid)
        {
            //            if (Util.IsDebug())
            //            {
            //                var q = from om in DbUtil.Db.OrganizationMembers
            //                    where om.OrganizationId == 89924
            //                    select om;
            //                foreach (var om in q)
            //                    om.Drop(DbUtil.Db, addToHistory: false);
            //                    //        DbUtil.Db.PurgePerson(om.PeopleId);
            //                var dr = DbUtil.Db.People.SingleOrDefault(mm => mm.Name == "David Roll");
            //                if(dr != null)
            //                    foreach(var mm in dr.Family.People)
            //                        if(mm.PeopleId != dr.PeopleId)
            //                            DbUtil.Db.PurgePerson(mm.PeopleId);
            //                DbUtil.Db.SubmitChanges();
            //            }
            if (DbUtil.Db.Roles.Any(rr => rr.RoleName == "disabled"))
                return Content("Site is disabled for maintenance, check back later");
            Util.NoCache(Response);
            if (!id.HasValue)
                return Content("no organization");
            var m = new OnlineRegModel { Orgid = id };
            if (m.org == null && m.masterorg == null)
                return Content("invalid registration");

            if (m.masterorg != null)
            {
                if (!OnlineRegModel.UserSelectClasses(m.masterorg).Any())
                    return Content("no classes available on this org");
            }
            else if (m.org != null)
            {
                if ((m.org.RegistrationTypeId ?? 0) == RegistrationTypeCode.None)
                    return Content("no registration allowed on this org");
                if (m.org.IsMissionTrip == true)
                {
                    if (gsid.HasValue)
                    {
                        var gs = DbUtil.Db.GoerSupporters.Single(gg => gg.Id == gsid);
                        m.GoerId = gs.GoerId;
                        m.GoerSupporterId = gsid;
                    }
                    else if (goerid.HasValue)
                    {
                        m.GoerId = goerid;
                    }
                }
            }
            m.URL = Request.Url.OriginalString;

            SetHeaders(m);

            m.testing = testing == true || DbUtil.Db.Setting("OnlineRegTesting", Util.IsDebug() ? "true" : "false").ToBool();

            if (Util.ValidEmail(email) || login != true)
                m.nologin = true;

            if (m.nologin)
                m.CreateList();
            else
                m.List = new List<OnlineRegPersonModel>();

            if (Util.ValidEmail(email))
                m.List[0].EmailAddress = email;

            var pid = 0;
            if (registertag.HasValue())
            {
                var guid = registertag.ToGuid();
                if (guid == null)
                    return Content("invalid link");
                var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                if (ot == null)
                    return Content("invalid link");
            #if DEBUG
            #else
                if (ot.Used)
                    return Content("link used");
            #endif
                if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                    return Content("link expired");
                var a = ot.Querystring.Split(',');
                pid = a[1].ToInt();
                m.registertag = registertag;
            }
            else if (User.Identity.IsAuthenticated)
            {
                pid = Util.UserPeopleId ?? 0;
            }

            if (pid > 0)
            {
                //m.List = new List<OnlineRegPersonModel>();
                m.UserPeopleId = pid;
                OnlineRegPersonModel p = null;
                if (showfamily != true)
                {
                    p = m.LoadExistingPerson(pid, 0);
                    p.ValidateModelForFind(ModelState, m);
                    p.LoggedIn = true;
                    if (m.masterorg == null)
                    {
                        if (m.List.Count == 0)
                            m.List.Add(p);
                        else
                            m.List[0] = p;
                    }
                }
                if (!ModelState.IsValid)
                    return View(m);

                if (m.masterorg != null && m.masterorg.RegistrationTypeId == RegistrationTypeCode.ManageSubscriptions2)
                {
                    TempData["ms"] = m.UserPeopleId;
                    return Redirect("/OnlineReg/ManageSubscriptions/{0}".Fmt(m.masterorgid));
                }
                if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.ManageGiving)
                {
                    TempData["mg"] = m.UserPeopleId;
                    return ManageGiving(m.Orgid.ToString(), m.testing);
                    //return Redirect("/OnlineReg/ManageGiving/{0}".Fmt(m.Orgid));
                }
                if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.OnlinePledge)
                {
                    TempData["mp"] = m.UserPeopleId;
                    return Redirect("/OnlineReg/ManagePledge/{0}".Fmt(m.Orgid));
                }
                if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.ChooseVolunteerTimes)
                {
                    TempData["ps"] = m.UserPeopleId;
                    return Redirect("/OnlineReg/ManageVolunteer/{0}".Fmt(m.Orgid));
                }
                if (showfamily != true && p.org != null && p.Found == true)
                {
                    p.IsFilled = p.org.RegLimitCount(DbUtil.Db) >= p.org.Limit;
                    if (p.IsFilled)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[0].Found), "Sorry, but registration is closed.");
                    if (p.Found == true)
                        p.FillPriorInfo();
                    CheckSetFee(m, p);
                    m.History.Add("index, pid={0}, !showfamily, p.org, found=true".Fmt(pid));
                    return View(m);
                }
                m.History.Add("index, pid=" + pid);
                return View(m);
            }
            m.History.Add("index");
            return View(m);
        }
Exemplo n.º 8
0
        public static PaymentForm CreatePaymentForm(OnlineRegModel m)
        {
            var r = m.GetTransactionInfo();
            if (r == null)
                return null;

            var pf = new PaymentForm
            {
                AmtToPay = m.PayAmount() + (m.donation ?? 0),
                AskDonation = m.AskDonation(),
                AllowCoupon = !m.OnlineGiving(),
                PayBalance = false,
                Amtdue = m.TotalAmount() + (m.donation ?? 0),
                Donate = m.donation,
                Description = m.DescriptionForPayment,
                Email = r.Email,
                First = r.First,
                MiddleInitial = r.Middle,
                Last = r.Last,
                Suffix = r.Suffix,
                IsLoggedIn = m.UserPeopleId.HasValue,
                OrgId = m.List[0].orgid,
                Url = m.URL,
                testing = m.testing ?? false,
                Terms = m.Terms,
                Address = r.Address,
                City = r.City,
                State = r.State,
                Zip = r.Zip,
                Phone = r.Phone,
            #if DEBUG2
                 CreditCard = "4111111111111111",
                 CCV = "123",
                 Expires = "1015",
                 Routing = "056008849",
                 Account = "12345678901234"
            #else
                CreditCard = r.payinfo.MaskedCard,
                Account = r.payinfo.MaskedAccount,
                Routing = r.payinfo.Routing,
                Expires = r.payinfo.Expires,
                MaskedCCV = Util.Mask(new StringBuilder(r.payinfo.Ccv), 0),
                CCV = r.payinfo.Ccv,
                SavePayInfo =
                   (r.payinfo.MaskedAccount != null && r.payinfo.MaskedAccount.StartsWith("X"))
                   || (r.payinfo.MaskedCard != null && r.payinfo.MaskedCard.StartsWith("X")),
                Type = r.payinfo.PreferredPaymentType,
            #endif
            };
            if (m.OnlineGiving())
            {
                pf.NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
                pf.IsGiving = true;
                pf.Type = r.payinfo.PreferredGivingType;
                if (pf.NoCreditCardsAllowed)
                    pf.Type = "B"; // bank account only
                else if (pf.NoEChecksAllowed)
                    pf.Type = "C"; // credit card only
            }
            pf.Type = pf.NoEChecksAllowed ? "C" : pf.Type;
            return pf;
        }
Exemplo n.º 9
0
        public static PaymentForm CreatePaymentForm(OnlineRegModel m)
        {
            var r = m.GetTransactionInfo();

            if (r == null)
            {
                return(null);
            }

            var pf = new PaymentForm
            {
                AmtToPay      = m.PayAmount() + (m.donation ?? 0),
                AskDonation   = m.AskDonation(),
                AllowCoupon   = !m.OnlineGiving(),
                PayBalance    = false,
                Amtdue        = m.TotalAmount() + (m.donation ?? 0),
                Donate        = m.donation,
                Description   = m.Header,
                Email         = r.Email,
                First         = r.First,
                MiddleInitial = r.Middle,
                Last          = r.Last,
                Suffix        = r.Suffix,
                IsLoggedIn    = m.UserPeopleId.HasValue,
                OrgId         = m.List[0].orgid,
                Url           = m.URL,
                testing       = m.testing ?? false,
                Terms         = m.Terms,
                Address       = r.Address,
                City          = r.City,
                State         = r.State,
                Zip           = r.Zip,
                Phone         = r.Phone,
#if DEBUG2
                CreditCard = "4111111111111111",
                CCV        = "123",
                Expires    = "1015",
                Routing    = "056008849",
                Account    = "12345678901234"
#else
                CreditCard  = r.payinfo.MaskedCard,
                Account     = r.payinfo.MaskedAccount,
                Routing     = r.payinfo.Routing,
                Expires     = r.payinfo.Expires,
                MaskedCCV   = Util.Mask(new StringBuilder(r.payinfo.Ccv), 0),
                CCV         = r.payinfo.Ccv,
                SavePayInfo =
                    (r.payinfo.MaskedAccount != null && r.payinfo.MaskedAccount.StartsWith("X")) ||
                    (r.payinfo.MaskedCard != null && r.payinfo.MaskedCard.StartsWith("X")),
                Type = r.payinfo.PreferredPaymentType,
#endif
            };

            if (m.OnlineGiving())
            {
                pf.NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
                pf.IsGiving             = true;
                pf.Type = r.payinfo.PreferredGivingType;
                if (pf.NoCreditCardsAllowed)
                {
                    pf.Type = "B"; // bank account only
                }
                else if (pf.NoEChecksAllowed)
                {
                    pf.Type = "C"; // credit card only
                }
            }
            pf.Type = pf.NoEChecksAllowed ? "C" : pf.Type;
            return(pf);
        }
Exemplo n.º 10
0
 public OnlineRegPersonModel()
 {
     YesNoQuestion = new Dictionary<string, bool?>();
     FundItem = new Dictionary<int, decimal?>();
     Parent = HttpContext.Current.Items["OnlineRegModel"] as OnlineRegModel;
 }
Exemplo n.º 11
0
        public void ValidateModelForFind(ModelStateDictionary ModelState, OnlineRegModel m, bool selectfromfamily = false)
        {
            var i = Index();
            IsValidForContinue = true; // true till proven false
            if (UserSelectsOrganization())
                if ((classid ?? 0) == 0)
                {
                    var nameclassid = Parent.GetNameFor(mm => mm.List[i].classid);
                    const string pleaseChooseAGroupEvent = "please choose a group/event";
                    if (IsFamily)
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    else
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    IsValidForExisting = ModelState.IsValid;
                    return;
                }
            var dobname = Parent.GetNameFor(mm => mm.List[i].dob);
            var foundname = Parent.GetNameFor(mm => mm.List[i].Found);
            if (!PeopleId.HasValue)
                ValidBasic(ModelState);
            if (ComputesOrganizationByAge() && !birthday.HasValue)
                ModelState.AddModelError(dobname, "birthday required");
            var minage = DbUtil.Db.Setting("MinimumUserAge", "16").ToInt();
            if (orgid == Util.CreateAccountCode && age < minage)
                ModelState.AddModelError(dobname, "must be {0} to create account".Fmt(minage));
            if (!IsFamily && (!email.HasValue() || !Util.ValidEmail(email)))
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].email), "Please specify a valid email address.");
            if (ModelState.IsValid)
            {
                Found = person != null;
                if (count == 1)
                {
                    address = person.PrimaryAddress;
                    city = person.PrimaryCity;
                    state = person.PrimaryState;
                    zip = person.PrimaryZip;
                    gender = person.GenderId;
                    married = person.MaritalStatusId == 2 ? 2 : 1;

                    if (!person.EmailAddress.HasValue() &&
                        (ManageSubscriptions()
                            || orgid == Util.CreateAccountCode
                            || OnlineGiving()
                            || ManageGiving()
                            || OnlinePledge()
                        ))
                    {
                        ModelState.AddModelError(foundname, "No Email Address on record");
                        NotFoundText = @"We have found your record but we have no email address for you.<br/>
            This means that we cannot proceed until we have that to protect your data.<br/>
            Please call the church to resolve this before we can complete your information.";
                        IsValidForContinue = false;
                    }
                    else if (ComputesOrganizationByAge() && org == null)
                    {
                        if (selectfromfamily)
                            ModelState.AddModelError("age-" + person.PeopleId, "Sorry, cannot find an appropriate age group");
                        else
                            ModelState.AddModelError(dobname, "Sorry, cannot find an appropriate age group");
                        IsValidForContinue = false;
                    }
                    else if (MemberOnly() && person.MemberStatusId != MemberStatusCode.Member)
                    {
                        ModelState.AddModelError(foundname, "Sorry, must be a member of church");
                        IsValidForContinue = false;
                    }
                    else if (org != null)
                    {
                        var om = org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == PeopleId);
                        if (org.RegistrationTypeId == RegistrationTypeCode.CreateAccount)
                        {
            #if DEBUG
            #else
                            if (person.Users.Count() > 0)
                            {
                                ModelState.AddModelError(foundname, "You already have an account");
                                IsValidForContinue = false;
                            }
                            if (!Util.ValidEmail(person.EmailAddress))
                            {
                                ModelState.AddModelError(foundname, "You must have a valid email address on record");
                                NotFoundText = @"We have found your record but we do not have a valid email for you.<br/>
            For your protection, we cannot continue to create an account.<br />
            We can't use the one you enter online here since we can't be sure this is you.<br />
            Please call the church to resolve this before we can complete your account.<br />";
                                IsValidForContinue = false;
                            }
            #endif
                        }
                        else if (om != null && setting.AllowReRegister == false
                            && om.Organization.RegistrationTypeId != RegistrationTypeCode.ChooseVolunteerTimes)
                        {
                            ModelState.AddModelError(foundname, "This person is already registered");
                            IsValidForContinue = false;
                        }
                        else if (setting.ValidateOrgIds.Count > 0)
                        {
                            var reqmemberids = setting.ValidateOrgIds.Where(ii => ii > 0).ToList();
                            if (reqmemberids.Count > 0)
                                if (!person.OrganizationMembers.Any(mm => reqmemberids.Contains(mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must be member of specified organization");
                                    IsValidForContinue = false;
                                }
                            var reqnomemberids = setting.ValidateOrgIds.Where(ii => ii < 0).ToList();
                            if (reqnomemberids.Count > 0)
                                if (person.OrganizationMembers.Any(mm => reqnomemberids.Contains(-mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must be not be member of specified organization");
                                    IsValidForContinue = false;
                                }
                        }
                    }
                    if (m.List.Count(ii => ii.PeopleId == PeopleId) > 1)
                    {
                        ModelState.AddModelError(foundname, "Person already in Pending Registrations");
                        IsValidForContinue = false;
                    }
                }
                else if (count > 1)
                {
                    ModelState.AddModelError(foundname, "More than one match, sorry");
                    NotFoundText = @"We have found more than one record that matches your information
            This is an unexpected error and we don't know which one is you.
            Please call the church to resolve this before we can complete your registration.";
                    IsValidForContinue = false;
                }
                else if (count == 0)
                {
                    ModelState.AddModelError(foundname, "record not found");
                    NotFoundText =
            @"The first and last name in addition to either birthday, email, or phone,
            must match a record in the system.
            Please search with a different email, phone, or birthday.";
                }
            }
            ValidateBirthdayRange(ModelState);
            IsValidForExisting = ModelState.IsValid;
        }
Exemplo n.º 12
0
 public ActionResult Cancel(int id, OnlineRegModel m)
 {
     m.History.Add("Cancel id=" + id);
     m.List.RemoveAt(id);
     if (m.List.Count == 0)
         m.List.Add(new OnlineRegPersonModel
         {
             orgid = m.orgid,
             masterorgid = m.masterorgid,
             LoggedIn = m.UserPeopleId.HasValue,
     #if DEBUG
             first = "Another",
             last = "Child",
             dob = "12/1/02",
             email = "*****@*****.**",
     #endif
         });
     return FlowList(m, "Cancel");
 }
Exemplo n.º 13
0
 private ActionResult ErrorResult(OnlineRegModel m, Exception ex, string errorDisplay)
 {
     var d = new ExtraDatum { Stamp = Util.Now };
     d.Data = Util.Serialize<OnlineRegModel>(m);
     DbUtil.Db.ExtraDatas.InsertOnSubmit(d);
     DbUtil.Db.SubmitChanges();
     var ex2 = new Exception("{0}, {2}".Fmt(errorDisplay, d.Id, Util.ServerLink("/OnlineReg/RegPeople/") + d.Id), ex);
     ErrorSignal.FromCurrentContext().Raise(ex2);
     TempData["error"] = errorDisplay;
     return Content("/Error/");
 }
Exemplo n.º 14
0
 public ActionResult NoLogin(OnlineRegModel m)
 {
     m.nologin = true;
     m.CreateList();
     m.History.Add("nologin");
     return FlowList(m, "NoLogin");
 }
Exemplo n.º 15
0
        public ActionResult Login(OnlineRegModel m)
        {
            var ret = AccountModel.AuthenticateLogon(m.username, m.password, Session, Request);
            if (ret is string)
            {
                ModelState.AddModelError("authentication", ret.ToString());
                return FlowList(m, "Login");
            }
            Session["OnlineRegLogin"] = true;
            var user = ret as User;
            if (m.orgid == Util.CreateAccountCode)
                return Content("/Person/Index/" + Util.UserPeopleId);

            m.CreateList();
            m.UserPeopleId = user.PeopleId;

            if (m.ManagingSubscriptions())
            {
                TempData["ms"] = Util.UserPeopleId;
                return Content("/OnlineReg/ManageSubscriptions/{0}".Fmt(m.masterorgid));
            }
            if (m.ChoosingSlots())
            {
                TempData["ps"] = Util.UserPeopleId;
                return Content("/OnlineReg/ManageVolunteer/{0}".Fmt(m.orgid));
            }
            if (m.OnlinePledge())
            {
                TempData["mp"] = Util.UserPeopleId;
                return Content("/OnlineReg/ManagePledge/{0}".Fmt(m.orgid));
            }
            if (m.ManageGiving())
            {
                TempData["mg"] = Util.UserPeopleId;
                return Content("/OnlineReg/ManageGiving/{0}".Fmt(m.orgid));
            }

            if (m.UserSelectsOrganization())
                m.List[0].ValidateModelForFind(ModelState, m);
            m.List[0].LoggedIn = true;
            m.History.Add("login");
            return FlowList(m, "Login");
        }
Exemplo n.º 16
0
        // Main page
        public ActionResult Index(int? id, bool? testing, int? o, int? d, string email, bool? nologin, bool? login, string registertag, bool? showfamily)
        {
            #if DEBUG
            var om = DbUtil.Db.OrganizationMembers.SingleOrDefault(mm => mm.OrganizationId == 89469 && mm.PeopleId == 828612);
            if (om != null)
            {
                om.Drop(DbUtil.Db, false);
                DbUtil.Db.SubmitChanges();
            }
            #endif
            if (DbUtil.Db.Roles.Any(rr => rr.RoleName == "disabled"))
                return Content("Site is disabled for maintenance, check back later");
            Util.NoCache(Response);
            if (!id.HasValue)
                return Content("no organization");
            var m = new OnlineRegModel { orgid = id };
            if (m.org == null && m.masterorg == null)
                return Content("invalid registration");

            if (m.masterorg != null)
            {
                if (!OnlineRegModel.UserSelectClasses(m.masterorg).Any())
                    return Content("no classes available on this org");
            }
            else if (m.org != null)
            {
                if ((m.org.RegistrationTypeId ?? 0) == RegistrationTypeCode.None)
                    return Content("no registration allowed on this org");
            }
            m.URL = Request.Url.OriginalString;

            SetHeaders(m);

            #if DEBUG
            m.username = "******";
            m.testing = true;
            #else
            m.testing = testing;
            #endif
            if (Util.ValidEmail(email) || login != true)
                m.nologin = true;

            if (m.nologin)
                m.CreateList();
            else
                m.List = new List<OnlineRegPersonModel>();

            if (Util.ValidEmail(email))
                m.List[0].email = email;

            var pid = 0;
            if (registertag.HasValue())
            {
                var guid = registertag.ToGuid();
                if (guid == null)
                    return Content("invalid link");
                var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                if (ot == null)
                    return Content("invalid link");
            #if DEBUG
            #else
                if (ot.Used)
                    return Content("link used");
            #endif
                if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                    return Content("link expired");
                var a = ot.Querystring.Split(',');
                pid = a[1].ToInt();
                m.registertag = registertag;
            }
            else if (User.Identity.IsAuthenticated)
            {
                pid = Util.UserPeopleId ?? 0;
            }

            if (pid > 0)
            {
                //m.List = new List<OnlineRegPersonModel>();
                m.UserPeopleId = pid;
                OnlineRegPersonModel p = null;
                if (showfamily != true)
                {
                    p = m.LoadExistingPerson(pid, 0);
                    p.ValidateModelForFind(ModelState, m);
                    p.LoggedIn = true;
                    if (m.masterorg == null)
                    {
                        if (m.List.Count == 0)
                            m.List.Add(p);
                        else
                            m.List[0] = p;
                    }
                }
                if (!ModelState.IsValid)
                    return View(m);

                if (m.masterorg != null && m.masterorg.RegistrationTypeId == RegistrationTypeCode.ManageSubscriptions2)
                {
                    TempData["ms"] = m.UserPeopleId;
                    return Redirect("/OnlineReg/ManageSubscriptions/{0}".Fmt(m.masterorgid));
                }
                if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.ManageGiving)
                {
                    TempData["mg"] = m.UserPeopleId;
                    return Redirect("/OnlineReg/ManageGiving/{0}".Fmt(m.orgid));
                }
                if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.OnlinePledge)
                {
                    TempData["mp"] = m.UserPeopleId;
                    return Redirect("/OnlineReg/ManagePledge/{0}".Fmt(m.orgid));
                }
                if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.ChooseVolunteerTimes)
                {
                    TempData["ps"] = m.UserPeopleId;
                    return Redirect("/OnlineReg/ManageVolunteer/{0}".Fmt(m.orgid));
                }
                if (showfamily != true && p.org != null && p.Found == true)
                {
                    p.IsFilled = p.org.OrganizationMembers.Count() >= p.org.Limit;
                    if (p.IsFilled)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[0].Found), "Sorry, but registration is closed.");
                    if (p.Found == true)
                        p.FillPriorInfo();
                    CheckSetFee(m, p);
                    m.History.Add("index, pid={0}, !showfamily, p.org, found=true".Fmt(pid));
                    return View(m);
                }
                m.History.Add("index, pid=" + pid);
                return View(m);
            }
            m.History.Add("index");
            return View(m);
        }
Exemplo n.º 17
0
        public ActionResult CompleteRegistration(OnlineRegModel m)
        {
            m.History.Add("CompleteRegistration");

            if(m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.SpecialJavascript )
            {
                SpecialRegModel.ParseResults( m.orgid ?? 0, m.UserPeopleId ?? 0, Request.Form );
                return View( "SpecialRegistrationResults" );
            }

            if (m.AskDonation() && !m.donor.HasValue && m.donation > 0)
            {
                SetHeaders(m);
                ModelState.AddModelError("donation",
                     "Please indicate a donor or clear the donation amount");
                return View("AskDonation", m);
            }

            if (m.List.Count == 0)
                return Content("Can't find any registrants");

            RemmoveLastRegistrantIfEmpty(m);

            var d = new ExtraDatum { Stamp = Util.Now };
            d.Data = Util.Serialize<OnlineRegModel>(m);
            DbUtil.Db.ExtraDatas.InsertOnSubmit(d);
            DbUtil.Db.SubmitChanges();
            DbUtil.LogActivity("Online Registration: {0} ({1})".Fmt(m.Header, d.Id));

            if (m.PayAmount() == 0 && (m.donation ?? 0) == 0 && !m.Terms.HasValue())
                return RedirectToAction("Confirm",
                     new
                     {
                         id = d.Id,
                         TransactionID = "zero due",
                     });

            var terms = Util.PickFirst(m.Terms, "");
            if (terms.HasValue())
                ViewData["Terms"] = terms;

            SetHeaders(m);
            if (m.PayAmount() == 0 && m.Terms.HasValue())
            {
                return View("Terms", new PaymentModel
                     {
                         Terms = m.Terms,
                         _URL = m.URL,
                         _timeout = INT_timeout,
                         PostbackURL = Util.ServerLink("/OnlineReg/Confirm/" + d.Id),
                     });
            }

            ViewBag.timeout = INT_timeout;
            ViewBag.Url = m.URL;

            var om =
                 DbUtil.Db.OrganizationMembers.SingleOrDefault(
                      mm => mm.OrganizationId == m.orgid && mm.PeopleId == m.List[0].PeopleId);
            m.ParseSettings();

            if (om != null && m.settings[m.orgid.Value].AllowReRegister == false)
            {
                return Content("You are already registered it appears");
            }

            var pf = PaymentForm.CreatePaymentForm(m);
            pf.DatumId = d.Id;
            pf.FormId = Guid.NewGuid();
            if (OnlineRegModel.GetTransactionGateway() == "serviceu")
                return View("Payment", pf);
            return View("ProcessPayment", pf);
        }
Exemplo n.º 18
0
        public static PaymentForm CreatePaymentFormForBalanceDue(Transaction ti, decimal amtdue)
        {
            PaymentInfo pi = null;

            if (ti.Person != null && OnlineRegModel.GetTransactionGateway().Equal("sage"))
            {
                pi = ti.Person.PaymentInfos.FirstOrDefault();
            }
            if (pi == null)
            {
                pi = new PaymentInfo();
            }

            var pf = new PaymentForm
            {
                URL         = ti.Url,
                PayBalance  = true,
                AmtToPay    = amtdue,
                Amtdue      = 0,
                AllowCoupon = true,
                AskDonation = false,
                Description = ti.Description,
                OrgId       = ti.OrgId,
                OriginalId  = ti.OriginalId,
                Email       = Util.FirstAddress(ti.Emails).Address,
                FormId      = Guid.NewGuid(),

                First         = ti.First,
                MiddleInitial = ti.MiddleInitial.Truncate(1) ?? "",
                Last          = ti.Last,
                Suffix        = ti.Suffix,

                Phone   = ti.Phone,
                Address = ti.Address,
                City    = ti.City,
                State   = ti.State,
                Zip     = ti.Zip,
                testing = ti.Testing ?? false,
                TranId  = ti.Id,
#if DEBUG2
                CreditCard = "4111111111111111",
                CCV        = "123",
                Expires    = "1015",
                Routing    = "056008849",
                Account    = "12345678901234"
#else
                CreditCard  = pi.MaskedCard,
                MaskedCCV   = Util.Mask(new StringBuilder(pi.Ccv), 0),
                CCV         = pi.Ccv,
                Expires     = pi.Expires,
                Account     = pi.MaskedAccount,
                Routing     = pi.Routing,
                SavePayInfo =
                    (pi.MaskedAccount != null && pi.MaskedAccount.StartsWith("X")) ||
                    (pi.MaskedCard != null && pi.MaskedCard.StartsWith("X")),
#endif
            };

            pf.Type = pf.NoEChecksAllowed ? "C" : "";
            var org     = DbUtil.Db.LoadOrganizationById(ti.OrgId);
            var setting = new CmsData.Registration.Settings(org.RegSetting, DbUtil.Db, org.OrganizationId);

            pf.UseBootstrap = setting.UseBootstrap;
            return(pf);
        }
Exemplo n.º 19
0
        public void ValidateModelForFind(ModelStateDictionary ModelState, OnlineRegModel m, bool selectfromfamily = false)
        {
            var i = Index();

            IsValidForContinue = true;             // true till proven false
            if (UserSelectsOrganization())
            {
                if ((classid ?? 0) == 0)
                {
                    var          nameclassid             = Parent.GetNameFor(mm => mm.List[i].classid);
                    const string pleaseChooseAGroupEvent = "please choose a group/event";
                    if (IsFamily)
                    {
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    }
                    else
                    {
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    }
                    IsValidForExisting = ModelState.IsValid;
                    return;
                }
            }
            var dobname   = Parent.GetNameFor(mm => mm.List[i].dob);
            var foundname = Parent.GetNameFor(mm => mm.List[i].Found);

            if (!PeopleId.HasValue)
            {
                ValidBasic(ModelState);
            }
            if (ComputesOrganizationByAge() && !birthday.HasValue)
            {
                ModelState.AddModelError(dobname, "birthday required");
            }
            var minage = DbUtil.Db.Setting("MinimumUserAge", "16").ToInt();

            if (orgid == Util.CreateAccountCode && age < minage)
            {
                ModelState.AddModelError(dobname, "must be {0} to create account".Fmt(minage));
            }
            if (!IsFamily && (!email.HasValue() || !Util.ValidEmail(email)))
            {
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].email), "Please specify a valid email address.");
            }
            if (ModelState.IsValid)
            {
                Found = person != null;
                if (count == 1)
                {
                    address = person.PrimaryAddress;
                    city    = person.PrimaryCity;
                    state   = person.PrimaryState;
                    zip     = person.PrimaryZip;
                    gender  = person.GenderId;
                    married = person.MaritalStatusId == 2 ? 2 : 1;

                    if (!person.EmailAddress.HasValue() &&
                        (ManageSubscriptions() ||
                         orgid == Util.CreateAccountCode ||
                         OnlineGiving() ||
                         ManageGiving() ||
                         OnlinePledge()
                        ))
                    {
                        ModelState.AddModelError(foundname, "No Email Address on record");
                        NotFoundText       = @"We have found your record but we have no email address for you.<br/>
This means that we cannot proceed until we have that to protect your data.<br/>
Please call the church to resolve this before we can complete your information.";
                        IsValidForContinue = false;
                    }
                    else if (ComputesOrganizationByAge() && org == null)
                    {
                        if (selectfromfamily)
                        {
                            ModelState.AddModelError("age-" + person.PeopleId, "Sorry, cannot find an appropriate age group");
                        }
                        else
                        {
                            ModelState.AddModelError(dobname, "Sorry, cannot find an appropriate age group");
                        }
                        IsValidForContinue = false;
                    }
                    else if (MemberOnly() && person.MemberStatusId != MemberStatusCode.Member)
                    {
                        ModelState.AddModelError(foundname, "Sorry, must be a member of church");
                        IsValidForContinue = false;
                    }
                    else if (org != null)
                    {
                        var om = org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == PeopleId);
                        if (org.RegistrationTypeId == RegistrationTypeCode.CreateAccount)
                        {
#if DEBUG
#else
                            if (person.Users.Count() > 0)
                            {
                                ModelState.AddModelError(foundname, "You already have an account");
                                IsValidForContinue = false;
                            }
                            if (!Util.ValidEmail(person.EmailAddress))
                            {
                                ModelState.AddModelError(foundname, "You must have a valid email address on record");
                                NotFoundText       = @"We have found your record but we do not have a valid email for you.<br/>
For your protection, we cannot continue to create an account.<br />
We can't use the one you enter online here since we can't be sure this is you.<br />
Please call the church to resolve this before we can complete your account.<br />";
                                IsValidForContinue = false;
                            }
#endif
                        }
                        else if (om != null && setting.AllowReRegister == false &&
                                 om.Organization.RegistrationTypeId != RegistrationTypeCode.ChooseVolunteerTimes)
                        {
                            ModelState.AddModelError(foundname, "This person is already registered");
                            IsValidForContinue = false;
                        }
                        else if (setting.ValidateOrgIds.Count > 0)
                        {
                            var reqmemberids = setting.ValidateOrgIds.Where(ii => ii > 0).ToList();
                            if (reqmemberids.Count > 0)
                            {
                                if (!person.OrganizationMembers.Any(mm => reqmemberids.Contains(mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must be member of specified organization");
                                    IsValidForContinue = false;
                                }
                            }
                            var reqnomemberids = setting.ValidateOrgIds.Where(ii => ii < 0).ToList();
                            if (reqnomemberids.Count > 0)
                            {
                                if (person.OrganizationMembers.Any(mm => reqnomemberids.Contains(-mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must be not be member of specified organization");
                                    IsValidForContinue = false;
                                }
                            }
                        }
                    }
                    if (m.List.Count(ii => ii.PeopleId == PeopleId) > 1)
                    {
                        ModelState.AddModelError(foundname, "Person already in Pending Registrations");
                        IsValidForContinue = false;
                    }
                }
                else if (count > 1)
                {
                    ModelState.AddModelError(foundname, "More than one match, sorry");
                    NotFoundText       = @"We have found more than one record that matches your information
This is an unexpected error and we don't know which one is you.
Please call the church to resolve this before we can complete your registration.";
                    IsValidForContinue = false;
                }
                else if (count == 0)
                {
                    ModelState.AddModelError(foundname, "record not found");
                    NotFoundText =
                        @"The first and last name in addition to either birthday, email, or phone,
must match a record in the system.
Please search with a different email, phone, or birthday.";
                }
            }
            ValidateBirthdayRange(ModelState);
            IsValidForExisting = ModelState.IsValid;
        }
Exemplo n.º 20
0
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            ModelState.Clear();
            m.History.Add("SubmitNew id=" + id);
            var p = m.List[id];
            p.ValidateModelForNew(ModelState);

            if (ModelState.IsValid)
            {
                if (m.ManagingSubscriptions())
                {
                    p.IsNew = true;
                    m.ConfirmManageSubscriptions();
                    DbUtil.Db.SubmitChanges();
                    return View("ManageSubscriptions/OneTimeLink", m);
                }
                if (m.OnlinePledge())
                {
                    p.IsNew = true;
                    m.SendLinkForPledge();
                    DbUtil.Db.SubmitChanges();
                    SetHeaders(m);
                    return View("ManagePledge/OneTimeLink", m);
                }
                if (m.ManageGiving())
                {
                    p.IsNew = true;
                    m.SendLinkToManageGiving();
                    DbUtil.Db.SubmitChanges();
                    SetHeaders(m);
                    return View("ManageGiving/OneTimeLink", m);
                }
                if (p.ComputesOrganizationByAge())
                {
                    if (p.org == null)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].Found), "Sorry, cannot find an appropriate age group");
                    else if (p.org.RegEnd.HasValue && DateTime.Now > p.org.RegEnd)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].Found), "Sorry, registration has ended for that group");
                    else if (p.org.OrganizationStatusId == OrgStatusCode.Inactive)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].Found), "Sorry, that group is inactive");
                    else if (p.org.OrganizationStatusId == OrgStatusCode.Inactive)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].Found), "Sorry, that group is inactive");
                }
                else if (!p.ManageSubscriptions())
                {
                    p.IsFilled = p.org.RegLimitCount(DbUtil.Db) >= p.org.Limit;
                    if (p.IsFilled)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].DateOfBirth), "Sorry, that age group is filled");
                }
                p.IsNew = true;
            }
            p.IsValidForExisting = ModelState.IsValid == false;
            if (p.IsNew)
                p.FillPriorInfo();
            if (p.org != null && p.ShowDisplay() && p.ComputesOrganizationByAge())
                p.classid = p.org.OrganizationId;
            //if (!p.AnyOtherInfo())
            //    p.OtherOK = ModelState.IsValid;
            return FlowList(m, "SubmitNew");
        }
Exemplo n.º 21
0
 // Set suggested giving fee for an indidividual person
 private static void CheckSetFee(OnlineRegModel m, OnlineRegPersonModel p)
 {
     if (m.OnlineGiving() && p.setting.ExtraValueFeeName.HasValue())
     {
         var f = CmsWeb.Models.OnlineRegPersonModel.Funds().SingleOrDefault(ff => ff.Text == p.setting.ExtraValueFeeName);
         var evamt = p.person.GetExtra(p.setting.ExtraValueFeeName).ToDecimal();
         if (f != null && evamt > 0)
             p.FundItem[f.Value.ToInt()] = evamt;
     }
 }
Exemplo n.º 22
0
 private static void RemmoveLastRegistrantIfEmpty(OnlineRegModel m)
 {
     if (!m.last.IsNew && !m.last.Found == true)
         m.List.Remove(m.last);
     if (!(m.last.IsValidForNew || m.last.IsValidForExisting))
         m.List.Remove(m.last);
 }
Exemplo n.º 23
0
        public ActionResult PersonFind(int id, OnlineRegModel m)
        {
            m.History.Add("PersonFind id=" + id);

            if (id >= m.List.Count)
                return FlowList(m, "PersonFind");

            DbUtil.Db.SetNoLock();

            var p = m.List[id];
            if (p.IsValidForNew)
                return ErrorResult(m, new Exception("Unexpected onlinereg state: IsValidForNew is true and in PersonFind"), "PersonFind, unexpected state");

            if (p.classid.HasValue)
            {
                m.orgid = p.classid;
                m.classid = p.classid;
                p.orgid = p.classid;
            }
            p.PeopleId = null;
            p.ValidateModelForFind(ModelState, m);
            if (p.Found == true && m.org != null)
            {
                var setting = settings[m.org.OrganizationId];
                if (setting.AllowReRegister)
                {
                    var om = m.org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == p.PeopleId);
                    if (om != null)
                    {
                        m.ConfirmReregister();
                        DbUtil.Db.SubmitChanges();
                        ViewData["email"] = m.List[0].person.EmailAddress;
                        ViewData["orgname"] = m.org.OrganizationName;
                        ViewData["timeout"] = INT_timeout;
                        return View("ConfirmReregister");
                    }
                }
            }
            if (p.ManageSubscriptions()
                 || p.OnlinePledge()
                 || p.ManageGiving()
                 || m.ChoosingSlots())
            {
                p.OtherOK = true;
            }
            else if (p.org != null)
            {
                p.IsFilled = p.org.OrganizationMembers.Count() >= p.org.Limit;
                if (p.IsFilled)
                    ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].dob), "Sorry, but registration is closed.");
                if (p.Found == true)
                    p.FillPriorInfo();
            }
            if (p.org != null && p.ShowDisplay() && p.ComputesOrganizationByAge())
                p.classid = p.org.OrganizationId;

            CheckSetFee(m, p);

            return FlowList(m, "PersonFind");
        }
Exemplo n.º 24
0
 private ActionResult FlowList(OnlineRegModel m, string function)
 {
     try
     {
         var view = ViewExtensions2.RenderPartialViewToString2(this, "Flow/List", m);
         return Content(view);
     }
     catch (Exception ex)
     {
         return ErrorResult(m, ex, "In " + function + ex.Message);
     }
 }
Exemplo n.º 25
0
 public ActionResult Register(int id, OnlineRegModel m)
 {
     m.History.Add("Register");
     int index = m.List.Count - 1;
     if (m.List[index].classid.HasValue)
         m.classid = m.List[index].classid;
     var p = m.LoadExistingPerson(id, index);
     p.ValidateModelForFind(ModelState, m, selectfromfamily: true);
     if (!ModelState.IsValid)
         return FlowList(m, "Register");
     m.List[index] = p;
     if (p.ManageSubscriptions() && p.Found == true)
     {
         //p.OtherOK = true;
         return FlowList(m, "Register");
     }
     if (p.org != null && p.Found == true)
     {
         p.IsFilled = p.org.OrganizationMembers.Count() >= p.org.Limit;
         if (p.IsFilled)
             ModelState.AddModelError(m.GetNameFor(mm => mm.List[m.List.IndexOf(p)].Found), "Sorry, but registration is closed.");
         if (p.Found == true)
             p.FillPriorInfo();
         //if (!p.AnyOtherInfo())
         //p.OtherOK = true;
         return FlowList(m, "Register");
     }
     if (p.ShowDisplay() && p.org != null && p.ComputesOrganizationByAge())
         p.classid = p.org.OrganizationId;
     return FlowList(m, "Register");
 }
Exemplo n.º 26
0
        public void ValidateModelForFind(ModelStateDictionary ModelState, OnlineRegModel m, bool selectfromfamily = false)
        {
            var i = Index;
            IsValidForContinue = true; // true till proven false
            if (UserSelectsOrganization())
                if ((classid ?? 0) == 0)
                {
                    var nameclassid = Parent.GetNameFor(mm => mm.List[i].classid);
                    const string pleaseChooseAGroupEvent = "please choose a group/event";
                    if (IsFamily)
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    else
                        ModelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    IsValidForExisting = ModelState.IsValid;
                    return;
                }
            var dobname = Parent.GetNameFor(mm => mm.List[i].DateOfBirth);
            var foundname = Parent.GetNameFor(mm => mm.List[i].Found);
            if (IsFamily)
                foundname = "fammember-" + PeopleId;
            if (!PeopleId.HasValue)
                ValidBasic(ModelState);
            if (ComputesOrganizationByAge() && !birthday.HasValue)
                ModelState.AddModelError(dobname, "birthday required");
            var minage = DbUtil.Db.Setting("MinimumUserAge", "16").ToInt();
            if (orgid == Util.CreateAccountCode && age < minage)
                ModelState.AddModelError(dobname, "must be {0} to create account".Fmt(minage));
            if (!IsFamily && (!EmailAddress.HasValue() || !Util.ValidEmail(EmailAddress)))
                ModelState.AddModelError(Parent.GetNameFor(mm => mm.List[i].EmailAddress), "Please specify a valid email address.");
            if (ModelState.IsValid)
            {
                Found = person != null;
                if (count == 1)
                {
                    AddressLineOne = person.PrimaryAddress;
                    City = person.PrimaryCity;
                    State = person.PrimaryState;
                    ZipCode = person.PrimaryZip;
                    gender = person.GenderId;
                    married = person.MaritalStatusId == 2 ? 2 : 1;

                    if (!person.EmailAddress.HasValue() &&
                        (ManageSubscriptions()
                            || orgid == Util.CreateAccountCode
                            || OnlineGiving()
                            || ManageGiving()
                            || OnlinePledge()
                        ))
                    {
                        ModelState.AddModelError(foundname, "No Email Address on record");
                        NotFoundText = @"<strong>No Email Address on Record</strong><br/>
            We have found your record but we have no email address for you.<br/>
            This means that we cannot proceed until we have that to protect your data.<br/>
            Please call the church to resolve this before we can complete your information.";
                        IsValidForContinue = false;
                    }
                    else if (ComputesOrganizationByAge() && org == null)
                    {
                        var msg = NoAppropriateOrgError ?? "Sorry, no approprate org";
                        if (selectfromfamily)
                            ModelState.AddModelError("age-" + person.PeopleId, msg);
                        else
                            ModelState.AddModelError(dobname, msg);
                        IsValidForContinue = false;
                    }
                    else if (MemberOnly() && person.MemberStatusId != MemberStatusCode.Member)
                    {
                        ModelState.AddModelError(foundname, "Sorry, must be a member of church");
                        if(setting.UseBootstrap)
                            NotFoundText = @"<strong>Sorry, must be a member of this church</strong>";
                        IsValidForContinue = false;
                    }
                    else if (org != null)
                    {
                        var om = org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == PeopleId);
                        if (org.RegistrationTypeId == RegistrationTypeCode.CreateAccount)
                        {
            #if DEBUG
            #else
                            if (person.Users.Count() > 0)
                            {
                                ModelState.AddModelError(foundname, "You already have an account");
                                IsValidForContinue = false;
                            }
                            if (!Util.ValidEmail(person.EmailAddress))
                            {
                                ModelState.AddModelError(foundname, "You must have a valid email address on record");
                                NotFoundText = @"We have found your record but we do not have a valid email for you.<br/>
            For your protection, we cannot continue to create an account.<br />
            We can't use the one you enter online here since we can't be sure this is you.<br />
            Please call the church to resolve this before we can complete your account.<br />";
                                IsValidForContinue = false;
                            }
            #endif
                        }
                        else if (om != null && org.IsMissionTrip == true
                            && !Parent.SupportMissionTrip
                            && om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == "Sender")
                            && !om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == "Goer"))
                        {
                            IsValidForContinue = true;
                        }
                        else if (om != null && setting.AllowReRegister == false
                            && om.Organization.RegistrationTypeId != RegistrationTypeCode.ChooseVolunteerTimes
                            && !Parent.SupportMissionTrip)
                        {
                            ModelState.AddModelError(foundname, "This person is already registered");
                            if(setting.UseBootstrap || Parent.UseBootstrap)
                                NotFoundText = @"<strong>This person is already registered</strong>";
                            CancelText = "Regiser a different person";
                            IsValidForContinue = false;
                        }
                        else if (setting.ValidateOrgIds.Count > 0)
                        {
                            var reqmemberids = setting.ValidateOrgIds.Where(ii => ii > 0).ToList();
                            if (reqmemberids.Count > 0)
                                if (!person.OrganizationMembers.Any(mm => reqmemberids.Contains(mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must be member of specified organization");
                                    if(setting.UseBootstrap)
                                        NotFoundText = @"<strong>Must be a member of specified organization to register</strong>";
                                    IsValidForContinue = false;
                                }
                            var reqnomemberids = setting.ValidateOrgIds.Where(ii => ii < 0).ToList();
                            if (reqnomemberids.Count > 0)
                                if (person.OrganizationMembers.Any(mm => reqnomemberids.Contains(-mm.OrganizationId)))
                                {
                                    ModelState.AddModelError(foundname, "Must not be a member of specified organization");
                                    if(setting.UseBootstrap)
                                        NotFoundText = @"<strong>Must not be a member of specified organization to register</strong>";
                                    IsValidForContinue = false;
                                }
                        }
                    }
                    if (m.List.Count(ii => ii.PeopleId == PeopleId) > 1)
                    {
                        ModelState.AddModelError(foundname, "Person already in Pending Registration");
                        CancelText = "Regiser a different person";
                        if(setting.UseBootstrap)
                            NotFoundText = @"<strong>Person already in Pending Registration</strong>";
                        IsValidForContinue = false;
                    }
                }
                else if (count > 1)
                {
                    ModelState.AddModelError(foundname, "More than one match, sorry");
                    NotFoundText = @"<strong>MORE THAN ONE MATCH</strong><br />
            We have found more than one record that matches your information
            This is an unexpected error and we don't know which one is you.
            Please call the church to resolve this before we can complete your registration.";
                    IsValidForContinue = false;
                }
                else if (count == 0)
                {
                    ModelState.AddModelError(foundname, "record not found");
                    NotFoundText = @" <strong>RECORD NOT FOUND</strong><br />
                            We were not able to find you in our database. Please check the information you entered.
                            <ul>
                                <li>If everything looks good, select ""New Profile""</li>
                                <li>If you make a correction, select ""Search Again""</li>
                            </ul>";
                }
            }
            ValidateBirthdayRange(ModelState);
            IsValidForExisting = ModelState.IsValid;
        }
Exemplo n.º 27
0
 public ActionResult ShowMoreInfo(int id, OnlineRegModel m)
 {
     m.History.Add("ShowMoreInfo id=" + id);
     DbUtil.Db.SetNoLock();
     var p = m.List[id];
     p.ValidateModelForFind(ModelState, m);
     if (p.org != null && p.Found == true)
     {
         p.IsFilled = p.org.OrganizationMembers.Count() >= p.org.Limit;
         if (p.IsFilled)
             ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].dob), "Sorry, but registration is closed.");
         if (p.Found == true)
             p.FillPriorInfo();
         return FlowList(m, "ShowMoreInfo");
     }
     if (!p.whatfamily.HasValue && (id > 0 || p.LoggedIn == true))
     {
         ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].whatfamily), "Choose a family option");
         return FlowList(m, "ShowMoreInfo");
     }
     switch (p.whatfamily)
     {
         case 1:
             var u = DbUtil.Db.LoadPersonById(m.UserPeopleId.Value);
             p.address = u.PrimaryAddress;
             p.city = u.PrimaryCity;
             p.state = u.PrimaryState;
             p.zip = u.PrimaryZip.FmtZip();
             break;
         case 2:
             var pb = m.List[id - 1];
             p.address = pb.address;
             p.city = pb.city;
             p.state = pb.state;
             p.zip = pb.zip;
             break;
         default:
     #if DEBUG
             p.address = "235 Riveredge Cv.";
             p.city = "Cordova";
             p.state = "TN";
             p.zip = "38018";
             p.gender = 1;
             p.married = 10;
             p.homephone = "9017581862";
     #endif
             break;
     }
     p.ShowAddress = true;
     return FlowList(m, "ShowMoreInfo");
 }
Exemplo n.º 28
0
        private string ConfirmTransaction(OnlineRegModel m, string TransactionID, ExtraDatum ed = null)
        {
            m.ParseSettings();
            if (m.List.Count == 0)
                return "error: unexpected, no registrants found in confirmation";
            string confirm = "Confirm";
            var managingsubs = m.ManagingSubscriptions();
            var choosingslots = m.ChoosingSlots();
            var t = m.Transaction;
            if (t == null && !managingsubs && !choosingslots)
            {
                var pf = PaymentForm.CreatePaymentForm(m);
                if (ed != null)
                    pf.DatumId = ed.Id;
                t = pf.CreateTransaction(DbUtil.Db);
                m.TranId = t.Id;
                if (ed != null)
                {
                    m.History.Add("ConfirmTransaction");
                    ed.Completed = true;
                    ed.Data = Util.Serialize<OnlineRegModel>(m);
                    DbUtil.Db.SubmitChanges();
                }
            }
            if (t != null)
                ViewData["message"] = t.Message;

            if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.CreateAccount)
            {
                m.List[0].CreateAccount();
                ViewData["CreatedAccount"] = true;
                confirm = "ConfirmAccount";
            }
            else if (m.OnlineGiving())
            {
                var p = m.List[0];
                if (p.IsNew)
                    p.AddPerson(null, p.org.EntryPointId ?? 0);

                var staff = DbUtil.Db.StaffPeopleForOrg(p.org.OrganizationId)[0];
                var text = p.setting.Body.Replace("{church}", DbUtil.Db.Setting("NameOfChurch", "church"), ignoreCase:true);
                text = text.Replace("{amt}", (t.Amt ?? 0).ToString("N2"));
                text = text.Replace("{date}", DateTime.Today.ToShortDateString());
                text = text.Replace("{tranid}", t.Id.ToString());
                text = text.Replace("{name}", p.person.Name);
                text = text.Replace("{account}", "");
                text = text.Replace("{email}", p.person.EmailAddress);
                text = text.Replace("{phone}", p.person.HomePhone.FmtFone());
                text = text.Replace("{contact}", staff.Name);
                text = text.Replace("{contactemail}", staff.EmailAddress);
                text = text.Replace("{contactphone}", p.org.PhoneNumber.FmtFone());
                var re = new Regex(@"(?<b>.*?)<!--ITEM\sROW\sSTART-->(?<row>.*?)\s*<!--ITEM\sROW\sEND-->(?<e>.*)", RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
                var match = re.Match(text);
                var b = match.Groups["b"].Value;
                var row = match.Groups["row"].Value.Replace("{funditem}", "{0}").Replace("{itemamt}", "{1:N2}");
                var e = match.Groups["e"].Value;
                var sb = new StringBuilder(b);

                var desc = "{0}; {1}; {2}".Fmt(
                        p.person.Name,
                        p.person.PrimaryAddress,
                        p.person.PrimaryZip);
                foreach (var g in p.FundItemsChosen())
                {
                    if (g.amt > 0)
                    {
                        sb.AppendFormat(row, g.desc, g.amt);
                        p.person.PostUnattendedContribution(DbUtil.Db,
                                                            g.amt,
                                                            g.fundid,
                                                            desc);
                    }
                }
                t.Financeonly = true;
                if (t.Donate > 0)
                {
                    var fundname = DbUtil.Db.ContributionFunds.Single(ff => ff.FundId == p.setting.DonationFundId).FundName;
                    sb.AppendFormat(row, fundname, t.Donate);
                    t.Fund = p.setting.DonationFund();
                    p.person.PostUnattendedContribution(DbUtil.Db,
                        t.Donate.Value,
                        p.setting.DonationFundId,
                        desc);
                }
                sb.Append(e);
                if (!t.TransactionId.HasValue())
                {
                    t.TransactionId = TransactionID;
                    if (m.testing == true && !t.TransactionId.Contains("(testing)"))
                        t.TransactionId += "(testing)";
                }
                var contributionemail = (from ex in p.person.PeopleExtras
                                         where ex.Field == "ContributionEmail"
                                         select ex.Data).SingleOrDefault();
                if (contributionemail.HasValue())
                    contributionemail = contributionemail.Trim();
                if (!Util.ValidEmail(contributionemail))
                    contributionemail = p.person.FromEmail;

                Util.SendMsg(Util.SysFromEmail, Util.Host, Util.TryGetMailAddress(DbUtil.Db.StaffEmailForOrg(p.org.OrganizationId)),
                    p.setting.Subject, sb.ToString(),
                    Util.EmailAddressListFromString(contributionemail), 0, p.PeopleId);
                DbUtil.Db.Email(contributionemail, DbUtil.Db.StaffPeopleForOrg(p.org.OrganizationId),
                    "online giving contribution received",
                    "see contribution records for {0} ({1})".Fmt(p.person.Name, p.PeopleId));
                if (p.CreatingAccount == true)
                    p.CreateAccount();
            }
            else if (managingsubs)
            {
                m.ConfirmManageSubscriptions();
                m.URL = null;
                ViewData["ManagingSubscriptions"] = true;
                ViewData["CreatedAccount"] = m.List[0].CreatingAccount;
                confirm = "ConfirmAccount";
            }
            else if (choosingslots)
            {
                m.ConfirmPickSlots();
                m.URL = null;
                ViewData["ManagingVolunteer"] = true;
                ViewData["CreatedAccount"] = m.List[0].CreatingAccount;
                confirm = "ConfirmAccount";
            }
            else if (m.OnlinePledge())
            {
                m.ConfirmManagePledge();
                ViewData["ManagingPledge"] = true;
                ViewData["CreatedAccount"] = m.List[0].CreatingAccount;
                confirm = "ConfirmAccount";
            }
            else if (m.ManageGiving())
            {
                m.ConfirmManageGiving();
                ViewData["ManagingGiving"] = true;
                ViewData["CreatedAccount"] = m.List[0].CreatingAccount;
                confirm = "ConfirmAccount";
            }
            else if (t.TransactionGateway.ToLower() == "serviceu")
            {
                t.TransactionId = TransactionID;
                if (m.testing == true && !t.TransactionId.Contains("(testing)"))
                    t.TransactionId += "(testing)";
                t.Message = "Transaction Completed";
                t.Approved = true;
                m.EnrollAndConfirm();
                if (m.List.Any(pp => pp.PeopleId == null))
                {
                    LogOutOfOnlineReg();
                    return "error: no person";
                }
                m.UseCoupon(t.TransactionId, t.Amt ?? 0);
            }
            else
            {
                if (!t.TransactionId.HasValue())
                {
                    t.TransactionId = TransactionID;
                    if (m.testing == true && !t.TransactionId.Contains("(testing)"))
                        t.TransactionId += "(testing)";
                }
                m.EnrollAndConfirm();
                if (m.List.Any(pp => pp.PeopleId == null))
                {
                    LogOutOfOnlineReg();
                    return "error: no person";
                }
                m.UseCoupon(t.TransactionId, t.Amt ?? 0);
            }
            if (m.IsCreateAccount() || m.ManagingSubscriptions())
                ViewData["email"] = m.List[0].person.EmailAddress;
            else
                ViewData["email"] = m.List[0].email;

            if(m.masterorgid.HasValue && m.orgid.HasValue && !m.settings[m.orgid.Value].Subject.HasValue())
                ViewData["orgname"] = m.masterorg.OrganizationName;
            else
                ViewData["orgname"] = m.org != null ? m.org.OrganizationName : m.masterorg.OrganizationName;

            LogOutOfOnlineReg();
            return confirm;
        }
Exemplo n.º 29
0
        public static PaymentForm CreatePaymentForm(OnlineRegModel m)
        {
            var r = m.GetTransactionInfo();

            if (r == null)
            {
                return(null);
            }

            var pf = new PaymentForm
            {
                FormId        = Guid.NewGuid(),
                AmtToPay      = m.PayAmount() + (m.donation ?? 0),
                AskDonation   = m.AskDonation(),
                AllowCoupon   = !m.OnlineGiving(),
                PayBalance    = false,
                Amtdue        = m.TotalAmount() + (m.donation ?? 0),
                Donate        = m.donation,
                Description   = m.DescriptionForPayment,
                Email         = r.Email,
                First         = r.First,
                MiddleInitial = r.Middle,
                Last          = r.Last,
                Suffix        = r.Suffix,
                IsLoggedIn    = m.UserPeopleId.HasValue,
                OrgId         = m.List[0].orgid,
                URL           = m.URL,
                testing       = m.testing ?? false,
                Terms         = m.Terms,
                Address       = r.Address,
                Address2      = r.Address2,
                City          = r.City,
                State         = r.State,
                Country       = r.Country,
                Zip           = r.Zip,
                Phone         = r.Phone,
#if DEBUG2
                CreditCard = "4111111111111111",
                CVV        = "123",
                Expires    = "1015",
                Routing    = "056008849",
                Account    = "12345678901234"
#else
                CreditCard  = r.payinfo.MaskedCard,
                Account     = r.payinfo.MaskedAccount,
                Routing     = r.payinfo.Routing,
                Expires     = r.payinfo.Expires,
                SavePayInfo =
                    (r.payinfo.MaskedAccount != null && r.payinfo.MaskedAccount.StartsWith("X")) ||
                    (r.payinfo.MaskedCard != null && r.payinfo.MaskedCard.StartsWith("X")),
                Type = r.payinfo.PreferredPaymentType,
#endif
            };

            ClearMaskedNumbers(pf, r.payinfo);

            pf.AllowSaveProgress    = m.AllowSaveProgress();
            pf.NoCreditCardsAllowed = m.NoCreditCardsAllowed();
            if (m.OnlineGiving())
            {
                pf.NoCreditCardsAllowed = DbUtil.Db.Setting("NoCreditCardGiving", "false").ToBool();
                pf.IsGiving             = true;
                pf.FinanceOnly          = true;
                pf.Type = r.payinfo.PreferredGivingType;
            }
            else if (m.ManageGiving() || m.OnlinePledge())
            {
                pf.FinanceOnly = true;
            }
            if (pf.NoCreditCardsAllowed)
            {
                pf.Type = PaymentType.Ach; // bank account only
            }
            else if (pf.NoEChecksAllowed)
            {
                pf.Type = PaymentType.CreditCard; // credit card only
            }
            pf.Type    = pf.NoEChecksAllowed ? PaymentType.CreditCard : pf.Type;
            pf.DatumId = m.DatumId ?? 0;
            return(pf);
        }
Exemplo n.º 30
0
        public void Update()
        {
            var gateway = OnlineRegModel.GetTransactionGateway();

            if (gateway == "authorizenet")
            {
                var au = new AuthorizeNet(DbUtil.Db, testing);
                au.AddUpdateCustomerProfile(pid,
                                            Type,
                                            Cardnumber,
                                            Expires,
                                            Cardcode,
                                            Routing,
                                            Account);
            }
            else if (gateway == "sage")
            {
                var sg = new SagePayments(DbUtil.Db, testing);
                sg.storeVault(pid,
                              Type,
                              Cardnumber,
                              Expires,
                              Cardcode,
                              Routing,
                              Account,
                              giving: true);
            }
            else
            {
                throw new Exception("ServiceU not supported");
            }

            var mg = person.ManagedGiving();

            if (mg == null)
            {
                mg = new ManagedGiving();
                person.ManagedGivings.Add(mg);
            }
            mg.SemiEvery = SemiEvery;
            mg.Day1      = Day1;
            mg.Day2      = Day2;
            mg.EveryN    = EveryN;
            mg.Period    = Period;
            mg.StartWhen = StartWhen;
            mg.StopWhen  = StopWhen;
            mg.NextDate  = mg.FindNextDate(DateTime.Today);

            var pi = person.PaymentInfo();

            pi.FirstName     = FirstName.Truncate(50);
            pi.MiddleInitial = Middle.Truncate(10);
            pi.LastName      = LastName.Truncate(50);
            pi.Suffix        = Suffix.Truncate(10);
            pi.Address       = Address.Truncate(50);
            pi.City          = City.Truncate(50);
            pi.State         = State.Truncate(10);
            pi.Zip           = Zip.Truncate(15);
            pi.Phone         = Phone.Truncate(25);

            var q = from ra in DbUtil.Db.RecurringAmounts
                    where ra.PeopleId == pid
                    select ra;

            DbUtil.Db.RecurringAmounts.DeleteAllOnSubmit(q);
            DbUtil.Db.SubmitChanges();
            foreach (var c in FundItemsChosen())
            {
                var ra = new RecurringAmount
                {
                    PeopleId = pid,
                    FundId   = c.fundid,
                    Amt      = c.amt
                };
                DbUtil.Db.RecurringAmounts.InsertOnSubmit(ra);
            }
            DbUtil.Db.SubmitChanges();
        }
Exemplo n.º 31
0
 public ActionResult SubmitOtherInfo(int id, OnlineRegModel m)
 {
     m.History.Add("SubmitOtherInfo id=" + id);
     if (m.List.Count <= id)
         return Content("<p style='color:red'>error: cannot find person on submit other info</p>");
     m.List[id].ValidateModelForOther(ModelState);
     return FlowList(m, "SubmitOtherInfo");
 }
Exemplo n.º 32
0
        private void CheckBatchDates(DateTime start, DateTime end)
        {
            if (OnlineRegModel.GetTransactionGateway() != "sage")
            {
                return;
            }
            var sage    = new SagePayments(DbUtil.Db, false);
            var bds     = sage.SettledBatchSummary(start, end, true, true);
            var batches = from batch in bds.Tables[0].AsEnumerable()
                          select new
            {
                date      = batch["date"].ToDate().Value.AddHours(4),
                reference = batch["reference"].ToString(),
                type      = batch["type"].ToString()
            };

            foreach (var batch in batches)
            {
                if (DbUtil.Db.CheckedBatches.Any(tt => tt.BatchRef == batch.reference))
                {
                    continue;
                }

                var ds = sage.SettledBatchListing(batch.reference, batch.type);

                var items = from r in ds.Tables[0].AsEnumerable()
                            select new
                {
                    settled   = r["settle_date"].ToDate().Value.AddHours(4),
                    tranid    = r["order_number"],
                    reference = r["reference"].ToString(),
                    approved  = r["approved"].ToString().ToBool(),
                    name      = r["name"].ToString(),
                    message   = r["message"].ToString(),
                    amount    = r["total_amount"].ToString(),
                    date      = r["date"].ToDate(),
                    type      = r["transaction_code"].ToInt()
                };
                var settlelist = items.ToDictionary(ii => ii.reference, ii => ii);

                var q = from t in DbUtil.Db.Transactions
                        where settlelist.Keys.Contains(t.TransactionId)
                        where t.Approved == true
                        select t;
                var tlist = q.ToDictionary(ii => ii.TransactionId, ii => ii); // transactions that are found in setteled list;
                var q2    = from st in settlelist
                            where !tlist.Keys.Contains(st.Key)
                            select st.Value;
                var notbefore = DateTime.Parse("6/1/12");
                foreach (var st in q2)
                {
                    var    t = DbUtil.Db.Transactions.SingleOrDefault(j => j.TransactionId == st.reference && st.date >= notbefore);
                    string first, last;
                    Util.NameSplit(st.name, out first, out last);
                    var tt = new Transaction
                    {
                        Name               = st.name,
                        First              = first,
                        Last               = last,
                        TransactionId      = st.reference,
                        Amt                = st.amount.ToDecimal(),
                        Approved           = st.approved,
                        Message            = st.message,
                        TransactionDate    = st.date,
                        TransactionGateway = "sage",
                        Settled            = st.settled,
                        Batch              = batch.date,
                        Batchref           = batch.reference,
                        Batchtyp           = batch.type,
                        OriginalId         = t != null ? (t.OriginalId ?? t.Id) : (int?)null,
                        Fromsage           = true,
                        Description        = t != null ? t.Description : "no description from sage, id=" + st.tranid,
                    };
                    if (st.type == 6) // credit transaction
                    {
                        tt.Amt = -tt.Amt;
                    }
                    DbUtil.Db.Transactions.InsertOnSubmit(tt);
                }

                foreach (var t in q)
                {
                    if (!settlelist.ContainsKey(t.TransactionId))
                    {
                        continue;
                    }
                    t.Batch    = batch.date;
                    t.Batchref = batch.reference;
                    t.Batchtyp = batch.type;
                    t.Settled  = settlelist[t.TransactionId].settled;
                }
                var cb = DbUtil.Db.CheckedBatches.SingleOrDefault(bb => bb.BatchRef == batch.reference);
                if (cb == null)
                {
                    DbUtil.Db.CheckedBatches.InsertOnSubmit(
                        new CheckedBatch()
                    {
                        BatchRef = batch.reference,
                        CheckedX = DateTime.Now
                    });
                }
                else
                {
                    cb.CheckedX = DateTime.Now;
                }
                DbUtil.Db.SubmitChanges();
            }
        }
Exemplo n.º 33
0
 public ActionResult YesLogin(OnlineRegModel m)
 {
     m.History.Add("yeslogin");
     m.nologin = false;
     m.List = new List<OnlineRegPersonModel>();
     #if DEBUG
     m.username = "******";
     #endif
     return FlowList(m, "NoLogin");
 }
Exemplo n.º 34
0
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            m.History.Add("SubmitNew id=" + id);
            var p = m.List[id];
            p.ValidateModelForNew(ModelState);

            if (ModelState.IsValid)
            {
                if (m.ManagingSubscriptions())
                {
                    p.IsNew = true;
                    m.ConfirmManageSubscriptions();
                    ViewData["ManagingSubscriptions"] = true;
                    ViewData["CreatedAccount"] = m.List[0].CreatingAccount;
                    DbUtil.Db.SubmitChanges();
                    ViewData["email"] = m.List[0].person.EmailAddress;
                    ViewData["orgname"] = m.masterorg.OrganizationName;
                    ViewData["URL"] = m.URL;
                    ViewData["timeout"] = INT_timeout;
                    return View("ConfirmManageSub");
                }
                if (m.OnlinePledge())
                {
                    p.IsNew = true;
                    m.ConfirmManagePledge();
                    ViewData["CreatedAccount"] = m.List[0].CreatingAccount;
                    DbUtil.Db.SubmitChanges();
                    ViewData["email"] = m.List[0].person.EmailAddress;
                    ViewData["orgname"] = m.org.OrganizationName;
                    ViewData["URL"] = m.URL;
                    ViewData["timeout"] = INT_timeout;
                    SetHeaders(m);
                    return View("ConfirmManagePledge");
                }
                if (m.ManageGiving())
                {
                    p.IsNew = true;
                    m.ConfirmManageGiving();
                    ViewData["CreatedAccount"] = m.List[0].CreatingAccount;
                    DbUtil.Db.SubmitChanges();
                    ViewData["email"] = m.List[0].person.EmailAddress;
                    ViewData["orgname"] = m.org.OrganizationName;
                    ViewData["URL"] = m.URL;
                    ViewData["timeout"] = INT_timeout;
                    SetHeaders(m);
                    return View("ConfirmManageGiving");
                }
                if (p.org == null && p.ComputesOrganizationByAge())
                    ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].Found), "Sorry, cannot find an appropriate age group");
                else if (!p.ManageSubscriptions())
                {
                    p.IsFilled = p.org.OrganizationMembers.Count() >= p.org.Limit;
                    if (p.IsFilled)
                        ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].dob), "Sorry, that age group is filled");
                }
                p.IsNew = true;
            }
            p.IsValidForExisting = ModelState.IsValid == false;
            if (p.IsNew)
                p.FillPriorInfo();
            if (p.org != null && p.ShowDisplay() && p.ComputesOrganizationByAge())
                p.classid = p.org.OrganizationId;
            //if (!p.AnyOtherInfo())
            //    p.OtherOK = ModelState.IsValid;
            return FlowList(m, "SubmitNew");
        }
        public static void ValidateModelForFind(OnlineRegPersonModel model, ModelStateDictionary modelState, OnlineRegModel m, int i, bool selectFromFamily = false)
        {
            model.IsValidForContinue = true; // true till proven false
            if (model.UserSelectsOrganization())
            {
                if ((model.classid ?? 0) == 0)
                {
                    var          nameclassid             = model.Parent.GetNameFor(mm => mm.List[i].classid);
                    const string pleaseChooseAGroupEvent = "please choose a group/event";
                    if (model.IsFamily)
                    {
                        modelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    }
                    else
                    {
                        modelState.AddModelError(nameclassid, pleaseChooseAGroupEvent);
                    }
                    model.IsValidForExisting = modelState.IsValid;
                    return;
                }
            }

            var dobname   = model.Parent.GetNameFor(mm => mm.List[i].DateOfBirth);
            var foundname = model.Parent.GetNameFor(mm => mm.List[i].Found);

            if (model.IsFamily)
            {
                foundname = "fammember-" + model.PeopleId;
            }

            if (!model.PeopleId.HasValue)
            {
                ValidBasic(model, modelState, i);
            }

            if (model.ComputesOrganizationByAge() && !model.birthday.HasValue)
            {
                modelState.AddModelError(dobname, "birthday required");
            }

            var minage = DbUtil.Db.Setting("MinimumUserAge", "16").ToInt();

            if (model.orgid == Util.CreateAccountCode && model.age < minage)
            {
                modelState.AddModelError(dobname, "must be {0} to create account".Fmt(minage));
            }

            if (!model.IsFamily && (!model.EmailAddress.HasValue() || !Util.ValidEmail(model.EmailAddress)))
            {
                modelState.AddModelError(model.Parent.GetNameFor(mm => mm.List[i].person.EmailAddress), "Please specify a valid email address.");
            }

            if (modelState.IsValid)
            {
                model.Found = model.person != null;
                if (model.count == 1)
                {
                    model.AddressLineOne = model.person.PrimaryAddress;
                    model.City           = model.person.PrimaryCity;
                    model.State          = model.person.PrimaryState;
                    model.ZipCode        = model.person.PrimaryZip;
                    model.gender         = model.person.GenderId;
                    model.married        = model.person.MaritalStatusId == 2 ? 2 : 1;

                    if (!model.person.EmailAddress.HasValue() &&
                        (model.ManageSubscriptions() ||
                         model.orgid == Util.CreateAccountCode ||
                         model.OnlineGiving() ||
                         model.ManageGiving() ||
                         model.OnlinePledge()
                        ))
                    {
                        modelState.AddModelError(foundname, "No Email Address on record");
                        model.NotFoundText       = @"<strong>No Email Address on Record</strong><br/>
We have found your record but we have no email address for you.<br/>
This means that we cannot proceed until we have that to protect your data.<br/>
Please call the church to resolve this before we can complete your information.";
                        model.IsValidForContinue = false;
                    }
                    else if (model.ComputesOrganizationByAge() && model.org == null)
                    {
                        var msg = model.NoAppropriateOrgError ?? "Sorry, no approprate org";
                        if (selectFromFamily)
                        {
                            modelState.AddModelError("age-" + model.person.PeopleId, msg);
                        }
                        else
                        {
                            modelState.AddModelError(dobname, msg);
                        }
                        model.IsValidForContinue = false;
                    }
                    else if (model.MemberOnly() && model.person.MemberStatusId != MemberStatusCode.Member)
                    {
                        modelState.AddModelError(foundname, "Sorry, must be a member of church");
                        model.NotFoundText       = @"<strong>Sorry, must be a member of this church</strong>";
                        model.IsValidForContinue = false;
                    }
                    else if (model.org != null)
                    {
                        var om = model.org.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == model.PeopleId);
                        if (model.org.RegistrationTypeId == RegistrationTypeCode.CreateAccount)
                        {
#if DEBUG
#else
                            if (model.person.Users.Count() > 0)
                            {
                                modelState.AddModelError(foundname, "You already have an account");
                                model.IsValidForContinue = false;
                            }
                            if (!Util.ValidEmail(model.person.EmailAddress))
                            {
                                modelState.AddModelError(foundname, "You must have a valid email address on record");
                                model.NotFoundText       = @"We have found your record but we do not have a valid email for you.<br/>
For your protection, we cannot continue to create an account.<br />
We can't use the one you enter online here since we can't be sure this is you.<br />
Please call the church to resolve this before we can complete your account.<br />";
                                model.IsValidForContinue = false;
                            }
#endif
                        }
                        else if (om != null && model.org.IsMissionTrip == true &&
                                 !model.Parent.SupportMissionTrip &&
                                 om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == "Sender") &&
                                 !om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == "Goer"))
                        {
                            model.IsValidForContinue = true;
                        }
                        else if (om != null && model.setting.AllowReRegister == false &&
                                 om.Organization.RegistrationTypeId != RegistrationTypeCode.ChooseVolunteerTimes &&
                                 !model.Parent.SupportMissionTrip)
                        {
                            modelState.AddModelError(foundname, "This person is already registered");
                            model.NotFoundText       = @"<strong>This person is already registered</strong>";
                            model.CancelText         = "Register a different person";
                            model.IsValidForContinue = false;
                        }
                        else if (model.setting.ValidateOrgIds.Count > 0 && !model.Parent.SupportMissionTrip)
                        {
                            var reqmemberids = model.setting.ValidateOrgIds.Where(ii => ii > 0).ToList();
                            if (reqmemberids.Count > 0)
                            {
                                if (!model.person.OrganizationMembers.Any(mm => reqmemberids.Contains(mm.OrganizationId)))
                                {
                                    modelState.AddModelError(foundname, "Must be member of specified organization");
                                    model.NotFoundText       = @"<strong>Must be a member of specified organization to register</strong>";
                                    model.IsValidForContinue = false;
                                }
                            }
                            var reqnomemberids = model.setting.ValidateOrgIds.Where(ii => ii < 0).ToList();
                            if (reqnomemberids.Count > 0)
                            {
                                if (model.person.OrganizationMembers.Any(mm => reqnomemberids.Contains(-mm.OrganizationId)))
                                {
                                    modelState.AddModelError(foundname, "Must not be a member of specified organization");
                                    model.NotFoundText       = @"<strong>Must not be a member of specified organization to register</strong>";
                                    model.IsValidForContinue = false;
                                }
                            }
                        }
                    }
                    if (m.List.Count(ii => ii.PeopleId == model.PeopleId) > 1)
                    {
                        modelState.AddModelError(foundname, "Person already in Pending Registration");
                        model.CancelText         = "Register a different person";
                        model.NotFoundText       = @"<strong>Person already in Pending Registration</strong>";
                        model.IsValidForContinue = false;
                    }
                }
                else if (model.count > 1)
                {
                    modelState.AddModelError(foundname, "More than one match, sorry");
                    model.NotFoundText       = @"<strong>MORE THAN ONE MATCH</strong><br />
We have found more than one record that matches your information
This is an unexpected error and we don't know which one is you.
Please call the church to resolve this before we can complete your registration.";
                    model.IsValidForContinue = false;
                }
                else if (model.count == 0)
                {
                    modelState.AddModelError(foundname, "record not found");
                    model.NotFoundText = @" <strong>RECORD NOT FOUND</strong><br />
                            We were not able to find you in our database. Please check the information you entered.
                            <ul>
                                <li>If everything looks good, select ""New Profile""</li>
                                <li>If you make a correction, select ""Search Again""</li>
                            </ul>";
                }
            }
            ValidateBirthdayRange(model, modelState, i);
            model.IsValidForExisting = modelState.IsValid;
        }
Exemplo n.º 36
0
        private Transaction ProcessPaymentTransaction(OnlineRegModel m, PaymentForm pf)
        {
            Transaction ti = null;
            if (m != null && m.Transaction != null)
                ti = PaymentForm.CreateTransaction(DbUtil.Db, m.Transaction, pf.AmtToPay);
            else
                ti = pf.CreateTransaction(DbUtil.Db);

            int? pid = null;
            if (m != null)
            {
                m.ParseSettings();
                var terms = Util.PickFirst(m.Terms, "");
                if (terms.HasValue())
                    ViewData["Terms"] = terms;
                pid = m.UserPeopleId;
                if (m.TranId == null)
                    m.TranId = ti.Id;
            }

            if (!pid.HasValue)
            {
                var pds = DbUtil.Db.FindPerson(pf.First, pf.Last, null, pf.Email, pf.Phone);
                if (pds.Count() == 1)
                    pid = pds.Single().PeopleId.Value;
            }
            TransactionResponse tinfo;
            var gateway = OnlineRegModel.GetTransactionGateway();
            if (gateway == "authorizenet")
                if (pf.SavePayInfo == true)
                {
                    var anet = new AuthorizeNet(DbUtil.Db, pf.testing);
                    tinfo = anet.createCustomerProfileTransactionRequest(
                        pid ?? 0,
                        pf.AmtToPay ?? 0,
                        pf.Description,
                        pf.TranId ?? 0);
                }
                else
                    if (pf.Type == "B")
                        tinfo = OnlineRegModel.PostECheck(
                            pf.Routing, pf.Account,
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.First, pf.Last,
                            pf.Address, pf.City, pf.State, pf.Zip,
                            pf.testing);
                    else
                        tinfo = OnlineRegModel.PostTransaction(
                            pf.CreditCard, pf.CCV,
                            Payments.NormalizeExpires(pf.Expires),
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.Email, pf.First, pf.Last,
                            pf.Address, pf.City, pf.State, pf.Zip,
                            pf.testing);
            else if (gateway == "sage")
                if (pf.SavePayInfo == true)
                {
                    var sage = new SagePayments(DbUtil.Db, pf.testing);
                    tinfo = sage.createVaultTransactionRequest(
                        pid ?? 0,
                        pf.AmtToPay ?? 0,
                        pf.Description,
                        ti.Id,
                        pf.Type);
                }
                else
                    if (pf.Type == "B")
                        tinfo = OnlineRegModel.PostVirtualCheckTransactionSage(
                            pf.Routing, pf.Account,
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.Email, pf.First, pf.MiddleInitial, pf.Last, pf.Suffix,
                            pf.Address, pf.City, pf.State, pf.Zip, pf.Phone,
                            pf.testing);
                    else
                        tinfo = OnlineRegModel.PostTransactionSage(
                            pf.CreditCard, pf.CCV,
                            Payments.NormalizeExpires(pf.Expires),
                            pf.AmtToPay ?? 0,
                            ti.Id, pf.Description,
                            pid ?? 0, pf.Email, pf.First, pf.MiddleInitial, pf.Last, pf.Suffix,
                            pf.Address, pf.City, pf.State, pf.Zip, pf.Phone,
                            pf.testing);

            else
                throw new Exception("unknown gateway " + gateway);

            ti.TransactionId = tinfo.TransactionId;
            if (ti.Testing == true && !ti.TransactionId.Contains("(testing)"))
                ti.TransactionId += "(testing)";
            ti.Approved = tinfo.Approved;
            if (ti.Approved == false)
            {
                ti.Amtdue += ti.Amt;
                if (m != null && m.OnlineGiving())
                    ti.Amtdue = 0;
            }
            ti.Message = tinfo.Message;
            ti.AuthCode = tinfo.AuthCode;
            ti.TransactionDate = DateTime.Now;
            DbUtil.Db.SubmitChanges();
            return ti;
        }
Exemplo n.º 37
0
        public Transaction CreateTransaction(CMSDataContext Db, decimal?amount = null, OnlineRegModel m = null)
        {
            if (!amount.HasValue)
            {
                amount = AmtToPay;
            }
            decimal?amtdue = null;

            if (Amtdue > 0)
            {
                amtdue = Amtdue - (amount ?? 0);
            }
            var ti = new Transaction
            {
                First              = First,
                MiddleInitial      = MiddleInitial.Truncate(1) ?? "",
                Last               = Last,
                Suffix             = Suffix,
                Donate             = Donate,
                Regfees            = AmtToPay,
                Amt                = amount,
                Amtdue             = amtdue,
                Emails             = Email,
                Testing            = testing,
                Description        = Description,
                OrgId              = OrgId,
                Url                = URL,
                TransactionGateway = OnlineRegModel.GetTransactionGateway(),
                Address            = Address.Truncate(50),
                Address2           = Address2.Truncate(50),
                City               = City,
                State              = State,
                Country            = Country,
                Zip                = Zip,
                DatumId            = DatumId,
                Phone              = Phone.Truncate(20),
                OriginalId         = OriginalId,
                Financeonly        = FinanceOnly,
                TransactionDate    = DateTime.Now,
                PaymentType        = Type,
                LastFourCC         = Type == PaymentType.CreditCard ? CreditCard.Last(4) : null,
                LastFourACH        = Type == PaymentType.Ach ? Account.Last(4) : null
            };

            Db.Transactions.InsertOnSubmit(ti);
            Db.SubmitChanges();
            if (OriginalId == null) // first transaction
            {
                ti.OriginalId = ti.Id;
            }
            return(ti);
        }