Beispiel #1
0
        private ActionResult RouteRegistration(OnlineRegModel m, int pid, bool?showfamily)
        {
            if (pid == 0)
            {
                return(View(m));
            }
#if DEBUG
            m.DebugCleanUp();
#endif

            var link = RouteExistingRegistration(m, pid);
            if (link.HasValue())
            {
                return(Redirect(link));
            }

            OnlineRegPersonModel p = null;
            if (showfamily != true)
            {
                // No need to pick family, so prepare first registrant ready to answer questions
                p = m.LoadExistingPerson(pid, 0);
                if (p == null)
                {
                    throw new Exception($"No person found with PeopleId = {pid}");
                }

                p.ValidateModelForFind(ModelState, 0);
                if (m.masterorg == null)
                {
                    if (m.List.Count == 0)
                    {
                        m.List.Add(p);
                    }
                    else
                    {
                        m.List[0] = p;
                    }
                }
            }
            if (!ModelState.IsValid)
            {
                m.Log("CannotProceed");
                return(View(m));
            }

            link = RouteManageGivingSubscriptionsPledgeVolunteer(m);
            if (link.HasValue())
            {
                if (m.ManageGiving()) // use Direct ActionResult instead of redirect
                {
                    return(ManageGiving(m.Orgid.ToString(), m.testing));
                }
                else if (m.RegisterLinkMaster())
                {
                    return(Redirect(link));
                }
                else
                {
                    return(Redirect(link));
                }
            }

            // check for forcing show family, master org, or not found
            if (showfamily == true || p.org == null || p.Found != true)
            {
                return(View(m));
            }

            // ready to answer questions, make sure registration is ok to go
            m.Log("Authorized");
            if (!m.SupportMissionTrip)
            {
                p.IsFilled = p.org.RegLimitCount(DbUtil.Db) >= p.org.Limit;
            }
            if (p.IsFilled)
            {
                m.Log("Closed");
                ModelState.AddModelError(m.GetNameFor(mm => mm.List[0].Found), "Sorry, but registration is closed.");
            }

            p.FillPriorInfo();
            p.SetSpecialFee();

            m.HistoryAdd($"index, pid={pid}, !showfamily, p.org, found=true");
            return(View(m));
        }
Beispiel #2
0
        private ActionResult RouteRegistration(OnlineRegModel m, int pid, bool?showfamily)
        {
            if (pid == 0)
            {
                return(View(m));
            }
#if DEBUG
            m.DebugCleanUp();
#endif
            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);

            if ((int)GatewayTypes.Pushpay == GatewayId && m.ProcessType == PaymentProcessTypes.OneTimeGiving)
            {
                Session["PaymentProcessType"] = PaymentProcessTypes.OneTimeGiving;
                return(Redirect($"/Pushpay/OneTime/{pid}/{m.Orgid}"));
            }

            if ((int)GatewayTypes.Pushpay == GatewayId && m.ProcessType == PaymentProcessTypes.RecurringGiving)
            {
                Session["PaymentProcessType"] = PaymentProcessTypes.RecurringGiving;
                return(Redirect($"/Pushpay/RecurringManagment/{pid}/{m.Orgid}"));
            }

            var link = RouteExistingRegistration(m, pid);
            if (link.HasValue())
            {
                return(Redirect(link));
            }

            OnlineRegPersonModel p;
            PrepareFirstRegistrant(ref m, pid, showfamily, out p);
            if (p != null)
            {
                p.pledgeFundId = m.pledgeFundId;
            }

            if (!ModelState.IsValid)
            {
                m.Log("CannotProceed");
                return(View(m));
            }

            link = RouteManageGivingSubscriptionsPledgeVolunteer(m);
            if (link.HasValue())
            {
                if (m.ManageGiving()) // use Direct ActionResult instead of redirect
                {
                    return(ManageGiving(m.Orgid.ToString(), m.testing));
                }
                else if (m.RegisterLinkMaster())
                {
                    return(Redirect(link));
                }
                else
                {
                    return(Redirect(link));
                }
            }

            // check for forcing show family, master org, or not found
            if (showfamily == true || p.org == null || p.Found != true)
            {
                return(View(m));
            }

            // ready to answer questions, make sure registration is ok to go
            m.Log("Authorized");
            if (!m.SupportMissionTrip)
            {
                p.IsFilled = p.org.RegLimitCount(CurrentDatabase) >= p.org.Limit;
            }
            if (p.IsFilled)
            {
                m.Log("Closed");
                ModelState.AddModelError(m.GetNameFor(mm => mm.List[0].Found), "Sorry, but registration is closed.");
            }

            p.FillPriorInfo();
            p.SetSpecialFee();

            m.HistoryAdd($"index, pid={pid}, !showfamily, p.org, found=true");
            return(View(m));
        }