public ActionResult Login(OnlineRegModel m)
        {
            fromMethod = "Login";
            // they clicked the Login button on the login page

//            var ret = Util.IsDebug() && Util.IsLocalNetworkRequest
//                ? AccountModel.AutoLogin(m.username, Session, Request) :
            var ret = AccountModel.AuthenticateLogon(m.username, m.password, Session, Request);

            if (ret is string)
            {
                ModelState.AddModelError("authentication", ret.ToString());
                return FlowList(m);
            }
            Session["OnlineRegLogin"] = true;

            if (m.Orgid == Util.CreateAccountCode)
            {
                DbUtil.LogActivity("OnlineReg CreateAccount Existing", peopleid: Util.UserPeopleId, datumId: m.DatumId);
                return Content("/Person2/" + Util.UserPeopleId); // they already have an account, so take them to their page
            }
            m.UserPeopleId = Util.UserPeopleId;
            var route = RouteSpecialLogin(m);
            if (route != null)
                return route;

            m.HistoryAdd("login");
            return FlowList(m);
        }
 public ActionResult Cancel(int id, OnlineRegModel m)
 {
     // After clicking Cancel, remove a person from the completed registrants list
     fromMethod = "Cancel";
     m.CancelRegistrant(id);
     return FlowList(m);
 }
 public ActionResult CompleteRegistration(OnlineRegModel m)
 {
     if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.SpecialJavascript)
         m.List[0].SpecialTest = SpecialRegModel.ParseResults(Request.Form);
     TempData["onlineregmodel"] = Util.Serialize(m);
     return Redirect("/OnlineReg/CompleteRegistration");
 }
 public ActionResult NoLogin(OnlineRegModel m)
 {
     fromMethod = "NoLogin";
     // Clicked the register without logging in link
     m.nologin = true;
     m.CreateAnonymousList();
     m.Log("NoLogin");
     return FlowList(m);
 }
 public ActionResult AskDonation(OnlineRegModel m)
 {
     m.HistoryAdd("AskDonation");
     if (m.List.Count == 0)
     {
         m.Log("AskDonationError NoRegistrants");
         return Content("Can't find any registrants");
     }
     m.RemoveLastRegistrantIfEmpty();
     SetHeaders(m);
     return View(m);
 }
        public ActionResult YesLogin(OnlineRegModel m)
        {
            fromMethod = "YesLogin";
            // clicked the Login Here button
            m.HistoryAdd("yeslogin");
            m.nologin = false;
            m.List = new List<OnlineRegPersonModel>();
#if DEBUG
            m.username = "******";
#endif
            return FlowList(m);
        }
 public ActionResult AddAnotherPerson(OnlineRegModel m)
 {
     fromMethod = "AddAnotherPerson";
     m.HistoryAdd("AddAnotherPerson");
     m.ParseSettings();
     if (!ModelState.IsValid)
         return FlowList(m);
     m.List.Add(new OnlineRegPersonModel
     {
         orgid = m.Orgid,
         masterorgid = m.masterorgid,
     });
     return FlowList(m);
 }
 public ActionResult AddAnotherPerson(OnlineRegModel m)
 {
     fromMethod = "AddAnotherPerson";
     m.HistoryAdd("AddAnotherPerson");
     m.ParseSettings();
     if (!ModelState.IsValid)
         return FlowList(m);
     m.List.Add(new OnlineRegPersonModel
     {
         orgid = m.Orgid,
         masterorgid = m.masterorgid,
     #if DEBUG
         FirstName = "Delaine",
         LastName = "Carroll",
         EmailAddress = "*****@*****.**"
     #endif
     });
     return FlowList(m);
 }
Beispiel #9
0
        public ActionResult OnePageGiving(int id, bool? testing, string source)
        {
            Response.NoCache();
            try
            {
                var m = new OnlineRegModel(Request, id, testing, null, null, source);
                if (!m.ShouldPullSpecificFund())
                    throw new Exception("Must be a single fund OnlineGiving organization");
                SetHeaders(m);
                var pf = PaymentForm.CreatePaymentForm(m);
                pf.AmtToPay = null;
                pf.Type = pf.NoCreditCardsAllowed ? "B" : "C";
                pf.First = null;
                pf.Last = null;
                pf.Email = null;
                var p = m.List[0];
                if(pf.ShowCampusOnePageGiving)
                    pf.Campuses = p.Campuses().ToList();
                var funds = p.Funds();
                pf.Description = funds[0].Text;

            #if DEBUG
                pf.First = "Otis";
                pf.Last = "Sukamotis";
                pf.Email = "*****@*****.**";
                pf.Address = "135 Riveredge Cv";
                pf.Zip = "";
                pf.CreditCard = "3111111111111111";
                pf.Expires = "1018";
                pf.CVV = "123";
                pf.AmtToPay = 23M;
            #endif
                SetInstructions(m);

                return View("OnePageGiving/Index", pf);
            }
            catch (Exception ex)
            {
                if (ex is BadRegistrationException)
                    return Message(ex.Message);
                throw;
            }
        }
Beispiel #10
0
        // ReSharper disable once FunctionComplexityOverflow
        public ActionResult Index(int? id, bool? testing, string email, bool? login, string registertag, bool? showfamily, int? goerid, int? gsid, string source)
        {
            Response.NoCache();
            try
            {
                var m = new OnlineRegModel(Request, id, testing, email, login, source);
                if (m.org != null && m.org.IsMissionTrip == true)
                    m.PrepareMissionTrip(gsid, goerid);

                SetHeaders(m);
                var pid = m.CheckRegisterLink(registertag);
                return RouteRegistration(m, pid, showfamily);
            }
            catch (Exception ex)
            {
                if (ex is BadRegistrationException)
                    return Message(ex.Message);
                throw;
            }
        }
Beispiel #11
0
        public ActionResult Existing(int id)
        {
            var pid = Util.TempPeopleId;

            if (!pid.HasValue || pid == 0)
            {
                return(Message("not logged in"));
            }
            var m = OnlineRegModel.GetRegistrationFromDatum(id, CurrentDatabase);

            if (m == null)
            {
                return(Message("no Existing registration available"));
            }
            if (m.UserPeopleId != m.Datum.UserPeopleId)
            {
                return(Message("incorrect user"));
            }
            Util.TempPeopleId = pid;
            return(View("Continue/Existing", m));
        }
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            // Submit from AddressMaritalGenderForm
            fromMethod = "SubmitNew";
            ModelState.Clear();
            m.HistoryAdd("SubmitNew id=" + id);
            var p = m.List[id];

            if (p.ComputesOrganizationByAge())
            {
                p.orgid = null; // forget any previous information about selected org, may have new information like gender
            }
            p.ValidateModelForNew(ModelState, id);

            SetHeaders(m);
            var ret = p.AddNew(ModelState, id);

            return(ret.HasValue()
                ? View(ret, m)
                : FlowList(m));
        }
Beispiel #13
0
        public ActionResult ProcessExternalPayment(string reference)
        {
            PaymentForm pf = new PaymentForm(CurrentDatabase)
            {
                extTransactionId = 0
            };

            if (reference.Substring(0, 3) == "dat")
            {
                RegistrationDatum datum = CurrentDatabase.RegistrationDatas.SingleOrDefault(d => d.Id == Int32.Parse(reference.Substring(4)));
                OnlineRegModel    m     = Util.DeSerialize <OnlineRegModel>(datum.Data);
                m.CurrentDatabase = CurrentDatabase;
                pf = PaymentForm.CreatePaymentForm(m);
            }
            if (reference.Substring(0, 3) == "tra")
            {
                pf.extTransactionId = Int32.Parse(reference.Substring(4));
            }

            return(ProcessPayment(pf));
        }
Beispiel #14
0
        public ActionResult SubmitQuestions(int id, OnlineRegModel m)
        {
            var ret = m.CheckExpiredOrCompleted();

            if (ret.HasValue())
            {
                return(PageMessage(ret));
            }

            fromMethod = "SubmitQuestions";
            m.HistoryAdd("SubmitQuestions id=" + id);
            if (m.List.Count <= id)
            {
                return(Content("<p style='color:red'>error: cannot find person on submit other info</p>"));
            }

            bool supportGoerRequired = CurrentDatabase.Setting("MissionSupportRequiredGoer", "false").ToBool();

            m.List[id].ValidateModelQuestions(ModelState, id, supportGoerRequired);
            return(FlowList(m));
        }
Beispiel #15
0
        public ActionResult AddAnotherPerson(OnlineRegModel m)
        {
            fromMethod = "AddAnotherPerson";
            m.HistoryAdd("AddAnotherPerson");
            m.ParseSettings();
            if (!ModelState.IsValid)
            {
                return(FlowList(m));
            }
            m.List.Add(new OnlineRegPersonModel
            {
                orgid       = m.Orgid,
                masterorgid = m.masterorgid,
#if DEBUG
                FirstName    = "Delaine",
                LastName     = "Carroll",
                EmailAddress = "*****@*****.**"
#endif
            });
            return(FlowList(m));
        }
Beispiel #16
0
        public ActionResult Confirm(int?id, string transactionId, decimal?amount)
        {
            if (!id.HasValue)
            {
                return(View("Unknown"));
            }
            if (!transactionId.HasValue())
            {
                return(Content("error no transaction"));
            }

            var m = OnlineRegModel.GetRegistrationFromDatum(id ?? 0);

            if (m == null || m.Completed)
            {
                return(Content("no pending confirmation found"));
            }

            if (m.List.Count == 0)
            {
                return(Content("no registrants found"));
            }
            try
            {
                var view = ConfirmTransaction(m, transactionId);
                m.UpdateDatum(completed: true);
                SetHeaders(m);
                if (view == ConfirmEnum.ConfirmAccount)
                {
                    return(View("ConfirmAccount", m));
                }
                return(View("Confirm", m));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                TempData["error"] = ex.Message;
                return(Redirect("/Error"));
            }
        }
Beispiel #17
0
        // reached by the paylink in the confirmation email
        // which is produced in EnrollAndConfirm
        public ActionResult PayAmtDue(string q)
        {
            if (!q.HasValue())
            {
                return(Content("unknown"));
            }
            var id = Util.Decrypt(q).ToInt2();
            var qq = from t in DbUtil.Db.Transactions
                     where t.OriginalId == id || t.Id == id
                     orderby t.Id descending
                     select t;
            var ti = qq.FirstOrDefault();

            if (ti == null || ti.Amtdue == 0)
            {
                return(Content("no outstanding transaction"));
            }

#if DEBUG
            ti.Testing = true;
            if (!ti.Address.HasValue())
            {
                ti.Address = "235 Riveredge";
                ti.City    = "Cordova";
                ti.Zip     = "38018";
                ti.State   = "TN";
            }
#endif
            var pf = PaymentForm.CreatePaymentFormForBalanceDue(ti);
            SetHeaders(pf.OrgId ?? 0);

            ViewBag.Url     = pf.Url;
            ViewBag.timeout = INT_timeout;
            if (OnlineRegModel.GetTransactionGateway() != "serviceu")
            {
                return(View("ProcessPayment", pf));
            }
            ViewBag.TranId = ti.Id;
            return(View(pf));
        }
Beispiel #18
0
        public ActionResult AddAnotherPerson(OnlineRegModel m)
        {
            var ret = m.CheckExpiredOrCompleted();

            if (ret.HasValue())
            {
                return(PageMessage(ret));
            }
            fromMethod = "AddAnotherPerson";
            m.HistoryAdd("AddAnotherPerson");
            m.ParseSettings();
            if (!ModelState.IsValid)
            {
                return(FlowList(m));
            }
            m.List.Add(new OnlineRegPersonModel
            {
                orgid       = m.Orgid,
                masterorgid = m.masterorgid,
            });
            return(FlowList(m));
        }
Beispiel #19
0
        public ActionResult Giving(int id, int?goerid, int?gsid)
        {
            var m = new OnlineRegModel(Request, CurrentDatabase, id, false, null, null, null);

            if (m.org != null && m.org.IsMissionTrip == true && m.org.TripFundingPagesEnable == true)
            {
                m.PrepareMissionTrip(gsid, goerid);
            }
            else
            {
                return(new HttpNotFoundResult());
            }

            SetHeaders(m);
            if (m.MissionTripCost == null)
            {
                // goer specified isn't part of this trip
                return(new HttpNotFoundResult());
            }
            if (!m.URL.HasValue() || m.URL.Contains("False"))
            {
                m.URL = CurrentDatabase.ServerLink($"/OnlineReg/{id}/Giving/{goerid}");
            }

            var currentUserId = Util.UserPeopleId;

            if (currentUserId != null && currentUserId == goerid)
            {
                return(View("Giving/Goer", m));
            }
            else if (m.org.TripFundingPagesPublic)
            {
                return(View("Giving/Guest", m));
            }
            else
            {
                return(new HttpNotFoundResult());
            }
        }
Beispiel #20
0
        private void SetHeaders2(int id)
        {
            var org   = DbUtil.Db.LoadOrganizationById(id);
            var shell = "";

            if ((settings == null || !settings.ContainsKey(id)) && org != null)
            {
                var setting = OnlineRegModel.ParseSetting(org.RegSetting, id);
                shell = DbUtil.Content(setting.ShellBs, null);
            }
            if (!shell.HasValue() && settings != null && settings.ContainsKey(id))
            {
                shell = DbUtil.Content(settings[id].ShellBs, null);
            }
            if (!shell.HasValue())
            {
                shell = DbUtil.Content("ShellDefaultBs", "");
                if (!shell.HasValue())
                {
                    shell = DbUtil.Content("DefaultShellBs", "");
                }
            }


            if (shell.HasValue())
            {
                var re = new Regex(@"(.*<!--FORM START-->\s*).*(<!--FORM END-->.*)", RegexOptions.Singleline);
                var t  = re.Match(shell).Groups[1].Value.Replace("<!--FORM CSS-->", ViewExtensions2.OnlineReg2Css());
                ViewBag.hasshell = true;
                ViewBag.top      = t;
                var b = re.Match(shell).Groups[2].Value;
                ViewBag.bottom = b;
            }
            else
            {
                ViewBag.hasshell = false;
            }
        }
Beispiel #21
0
        public ActionResult RegisterLinkMaster(int id)
        {
            var pid = TempData["PeopleId"] as int?;

            ViewBag.Token = TempData["token"];

            var m = new OnlineRegModel {
                Orgid = id
            };

            if (User.Identity.IsAuthenticated)
            {
                return(View(otherRegisterlinkmaster, m));
            }

            if (pid == null)
            {
                return(Message("Must start with a registerlink"));
            }

            SetHeaders(id.ToInt());
            return(View(otherRegisterlinkmaster, m));
        }
Beispiel #22
0
        public ActionResult Registration(int DatumId)
        {
            OnlineRegModel    m      = new OnlineRegModel();
            decimal?          Amount = 0;
            string            mobile = string.Empty;
            RegistrationDatum datum  = CurrentDatabase.RegistrationDatas.SingleOrDefault(d => d.Id == DatumId);

            if (datum != null)
            {
                m = Util.DeSerialize <OnlineRegModel>(datum.Data);
                var pf = PaymentForm.CreatePaymentForm(m);
                //Needs to redirect in case cupons are enable.
                Amount = pf.AmtToPay;
                mobile = CurrentDatabase.People.SingleOrDefault(p => p.PeopleId == m.UserPeopleId)?.CellPhone;
            }
            else
            {
                ViewBag.Message = "Something went wrong";
                CurrentDatabase.LogActivity($"No datum founded with id: {DatumId}");
                return(View("~/Views/Shared/PageError.cshtml"));
            }
            return(Redirect($"{_givingLink}?ru={_merchantHandle}&sr=dat_{DatumId}&rcv=false&r=no&up={mobile}&a={Amount}&al=true&fndv=lock"));
        }
        public ActionResult RegisterLinkMaster(int id)
        {
            var pid = Util.TempPeopleId as int?;

            ViewBag.Token = Util.GetFromSession <string>("token");

            var m = new OnlineRegModel(CurrentDatabase)
            {
                Orgid = id
            };

            if (User.Identity.IsAuthenticated)
            {
                return(View(otherRegisterlinkmaster, m));
            }

            if (pid == null)
            {
                return(Message("Must start with a registerlink"));
            }

            SetHeaders(id.ToInt());
            return(View(otherRegisterlinkmaster, m));
        }
Beispiel #24
0
        public ActionResult Index(int?id, bool?testing, string email, bool?login, string registertag, bool?showfamily, int?goerid, int?gsid, string source)
        {
            Response.NoCache();
            try
            {
                var m = new OnlineRegModel(Request, id, testing, email, login, source);
                if (m.org != null && m.org.IsMissionTrip == true)
                {
                    m.PrepareMissionTrip(gsid, goerid);
                }

                SetHeaders(m);
                var pid = m.CheckRegisterLink(registertag);
                return(RouteRegistration(m, pid, showfamily));
            }
            catch (Exception ex)
            {
                if (ex is BadRegistrationException)
                {
                    return(Message(ex.Message));
                }
                throw;
            }
        }
Beispiel #25
0
        public ActionResult OnePageGiving(int id, bool?testing, string source)
        {
            Response.NoCache();
            try
            {
                var m = new OnlineRegModel(Request, CurrentDatabase, id, testing, null, null, source);

                var pid = Util.UserPeopleId;
                if (pid.HasValue)
                {
                    PrePopulate(m, pid.Value);
                }

                SetHeaders(m);
                m.CheckRegisterLink(null);

                if (m.NotActive())
                {
                    return(View("OnePageGiving/NotActive", m));
                }

                var pf = PaymentForm.CreatePaymentForm(m);
                pf.AmtToPay = null;

                if (string.IsNullOrWhiteSpace(pf.Type))
                {
                    pf.Type = pf.NoCreditCardsAllowed ? "B" : "C";
                }

#if DEBUG
                if (!pid.HasValue)
                {
                    pf.First      = "Otis";
                    pf.Last       = "Sukamotis";
                    pf.Email      = "*****@*****.**";
                    pf.Address    = "135 Riveredge Cv";
                    pf.Zip        = "";
                    pf.CreditCard = "3111111111111111";
                    pf.Expires    = "1018";
                    pf.CVV        = "123";
                    pf.AmtToPay   = 23M;
                }
#endif

                var p = m.List[0];
                if (pf.ShowCampusOnePageGiving)
                {
                    pf.Campuses = p.Campuses().ToList();
                }

                var designatedFund = p.DesignatedDonationFund().FirstOrDefault();
                pf.Description = designatedFund != null ? designatedFund.Text : m.DescriptionForPayment;

                SetInstructions(m);

                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }
            catch (Exception ex)
            {
                if (ex is BadRegistrationException)
                {
                    return(Message(ex.Message));
                }
                throw;
            }
        }
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            // Submit from AddressMaritalGenderForm
            fromMethod = "SubmitNew";
            ModelState.Clear();
            m.HistoryAdd("SubmitNew id=" + id);
            var p = m.List[id];
            p.ValidateModelForNew(ModelState, id);

            SetHeaders(m);
            var ret = p.AddNew(ModelState, id);
            return ret.HasValue()
                ? View(ret, m)
                : FlowList(m);
        }
Beispiel #27
0
        public ActionResult OnePageGivingLogin(int id, string username, string password, bool? testing, string source)
        {
            var ret = AccountModel.AuthenticateLogon(username, password, Session, Request);

            if (ret is string)
            {
                ModelState.AddModelError("loginerror", ret.ToString());
                var m = new OnlineRegModel(Request, id, testing, null, null, source);
                return View("OnePageGiving/Login", m);
            }
            Session["OnlineRegLogin"] = true;
            return Redirect($"/OnlineReg/{id}{(testing == true ? "?testing=true" : "")}");
        }
Beispiel #28
0
        public ActionResult CompleteRegistration()
        {
            Response.NoCache();
            var s = (string)TempData["onlineregmodel"];

            if (s == null)
            {
                return(Message("Registration cannot be completed after a page refresh."));
            }
            var m = Util.DeSerialize <OnlineRegModel>(s);

            m.HistoryAdd("CompleteRegistration");

            if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.SpecialJavascript)
            {
                var p = m.List[0];
                if (p.IsNew)
                {
                    p.AddPerson(null, p.org.EntryPointId ?? 0);
                }
                SpecialRegModel.SaveResults(m.Orgid ?? 0, m.List[0].PeopleId ?? 0, m.List[0].SpecialTest);
                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(Message("Can't find any registrants"));
            }

            RemoveLastRegistrantIfEmpty(m);

            m.UpdateDatum();
            DbUtil.LogActivity("Online Registration: {0} ({1})".Fmt(m.Header, m.DatumId));

            if (m.PayAmount() == 0 && (m.donation ?? 0) == 0 && !m.Terms.HasValue())
            {
                return(RedirectToAction("Confirm",
                                        new
                {
                    id = m.DatumId,
                    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,
                    PostbackURL = DbUtil.Db.ServerLink("/OnlineReg/Confirm/" + m.DatumId),
                    _timeout = m.TimeOut
                }));
            }

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

            m.ParseSettings();

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

            var pf = PaymentForm.CreatePaymentForm(m);

            if (OnlineRegModel.GetTransactionGateway() == "serviceu")
            {
                return(View("Payment/ServiceU", pf));
            }
            ModelState.Clear();
            return(View("Payment/Process", pf));
        }
Beispiel #29
0
 public ActionResult AutoSaveProgress(OnlineRegModel m)
 {
     try { m.UpdateDatum(); }
     catch { }
     return(Content(m.DatumId.ToString()));
 }
Beispiel #30
0
        public ActionResult CompleteRegistration(OnlineRegModel m)
        {
            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));
        }
Beispiel #31
0
        public ActionResult PersonFind(int id, OnlineRegModel m)
        {
            m.HistoryAdd("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;
            OnlineRegPersonModelValidator.ValidateModelForFind(p, ModelState, m, id);
            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();
                        return(View("ConfirmReregister", m));
                    }
                }
            }
            if (p.ManageSubscriptions() ||
                p.OnlinePledge() ||
                p.ManageGiving() ||
                m.ChoosingSlots())
            {
                p.OtherOK = true;
            }
            else if (p.org != null)
            {
                p.IsFilled = p.org.RegLimitCount(DbUtil.Db) >= p.org.Limit;
                if (p.IsFilled)
                {
                    ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].DateOfBirth), "Sorry, but registration is closed.");
                }
                if (p.Found == true)
                {
                    p.FillPriorInfo();
                }
            }
            if (p.org != null && p.ShowDisplay() && p.ComputesOrganizationByAge())
            {
                p.classid = p.org.OrganizationId;
            }

            p.CheckSetFee();

            return(FlowList(m, "PersonFind"));
        }
 private ActionResult FlowList(OnlineRegModel m)
 {
     try
     {
         m.UpdateDatum();
         m.Log(fromMethod);
         var content = ViewExtensions2.RenderPartialViewToString2(this, "Flow2/List", m);
         return Content(content);
     }
     catch (Exception ex)
     {
         return ErrorResult(m, ex, "In " + fromMethod + "<br>" + ex.Message);
     }
 }
        internal void PostContribution()
        {
            if (!(AmountGeneral > 0) && !(AmountGoer > 0))
            {
                return;
            }

            var org       = DbUtil.Db.LoadOrganizationById(OrgId);
            var notifyIds = DbUtil.Db.NotifyIds(org.GiftNotifyIds);
            var person    = DbUtil.Db.LoadPersonById(PeopleId ?? 0);
            var setting   = DbUtil.Db.CreateRegistrationSettings(OrgId ?? 0);
            var fund      = setting.DonationFundId;

            if (AmountGoer > 0)
            {
                var goerid = Goer.Value.ToInt();
                DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                    new GoerSenderAmount
                {
                    Amount      = AmountGoer,
                    GoerId      = goerid,
                    Created     = DateTime.Now,
                    OrgId       = org.OrganizationId,
                    SupporterId = PeopleId ?? 0,
                });
                var c = person.PostUnattendedContribution(DbUtil.Db,
                                                          AmountGoer ?? 0, fund,
                                                          $"SupportMissionTrip: org={OrgId}; goer={Goer.Value}", typecode: BundleTypeCode.MissionTrip);
                c.CheckNo = (CheckNo ?? "").Trim().Truncate(20);
                if (PeopleId == goerid)
                {
                    var om = DbUtil.Db.OrganizationMembers.Single(
                        mm => mm.PeopleId == goerid && mm.OrganizationId == OrgId);
                    var descriptionForPayment = OnlineRegModel.GetDescriptionForPayment(OrgId);
                    om.AddTransaction(DbUtil.Db, "Payment", AmountGoer ?? 0, "Payment", pmtDescription: descriptionForPayment);
                }
                // send notices
                var goer = DbUtil.Db.LoadPersonById(goerid);
                ToGoerName = "to " + goer.Name;
                DbUtil.Db.Email(notifyIds[0].FromEmail, goer, org.OrganizationName + "-donation",
                                $"{AmountGoer:C} donation received from {person.Name}");
                DbUtil.LogActivity("OrgMem SupportMissionTrip goer=" + goerid, OrgId, PeopleId);
            }
            if (AmountGeneral > 0)
            {
                DbUtil.Db.GoerSenderAmounts.InsertOnSubmit(
                    new GoerSenderAmount
                {
                    Amount      = AmountGeneral,
                    Created     = DateTime.Now,
                    OrgId       = org.OrganizationId,
                    SupporterId = PeopleId ?? 0
                });
                var c = person.PostUnattendedContribution(DbUtil.Db,
                                                          AmountGeneral ?? 0, fund,
                                                          $"SupportMissionTrip: org={OrgId}", typecode: BundleTypeCode.MissionTrip);
                if (CheckNo.HasValue())
                {
                    c.CheckNo = (CheckNo ?? "").Trim().Truncate(20);
                }

                DbUtil.LogActivity("OrgMem SupportMissionTrip", OrgId, PeopleId);
            }
            DbUtil.Db.SubmitChanges();
        }
Beispiel #34
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));
        }
        public ActionResult FindRecord(int id, OnlineRegModel m)
        {
            // Anonymous person clicks submit to find their record
            fromMethod = "FindRecord";
            m.HistoryAdd("FindRecord id=" + id);
            if (id >= m.List.Count)
                return FlowList(m);
            var p = m.List[id];

            if (p.NeedsToChooseClass())
                return FlowList(m);

            p.ValidateModelForFind(ModelState, id);

            if (p.AnonymousReRegistrant())
                return View("ConfirmReregister", m); // send email with link to reg-register

            if (p.IsSpecialReg())
                p.QuestionsOK = true;
            else if (p.RegistrationFull())
            {
                m.Log("Closed");
                ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].DateOfBirth), "Sorry, but registration is closed.");
            }

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

            if (!ModelState.IsValid || p.count == 1)
                return FlowList(m);

            // form is ok but not found, so show AddressGenderMarital Form
            p.PrepareToAddNewPerson(ModelState, id);
            p.Found = false;
            return FlowList(m);
        }
Beispiel #36
0
 private void SetInstructions(OnlineRegModel m)
 {
     var s = m.SubmitInstructions();
     ViewBag.Instructions = s.HasValue() ? s : $"<h4>{m.Header}</h4>";
 }
Beispiel #37
0
        private void SetInstructions(OnlineRegModel m)
        {
            var s = m.SubmitInstructions();

            ViewBag.Instructions = s.HasValue() ? s : $"<h4>{m.Header}</h4>";
        }
Beispiel #38
0
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            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;
                    if (m.masterorgid != null)
                    {
                        ViewData["orgname"] = m.masterorg.OrganizationName;
                    }
                    else
                    {
                        ViewData["orgname"] = m.div.Name;
                    }
                    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"));
        }
Beispiel #39
0
        public ActionResult Index(int?id, bool?testing, string email, bool?nologin, bool?login, string registertag, bool?showfamily, int?goerid, int?gsid, string source)
        {
            if (Util.IsDebug())
            {
                var q = from om in DbUtil.Db.OrganizationMembers
                        where om.OrganizationId == 89539 && om.PeopleId == 828612
                        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"));
            }
            Response.NoCache();
            if (!id.HasValue)
            {
                return(Message("no organization"));
            }

            MobileAppMenuController.Source = source;
            var m = new OnlineRegModel()
            {
                Orgid = id
            };

            if (m.org == null && m.masterorg == null)
            {
                return(Message("invalid registration"));
            }

            GoerSupporter goerSupporter = null; // used for mission trips

            if (m.masterorg != null)
            {
                if (!OnlineRegModel.UserSelectClasses(m.masterorg).Any())
                {
                    return(Message("no classes available on this org"));
                }
            }
            else if (m.org != null)
            {
                if ((m.org.RegistrationTypeId ?? 0) == RegistrationTypeCode.None)
                {
                    return(Message("no registration allowed on this org"));
                }
                if (m.org.IsMissionTrip == true)
                {
                    if (gsid.HasValue) // this means that the person is a suppoter who got a support email
                    {
                        goerSupporter = DbUtil.Db.GoerSupporters.SingleOrDefault(gg => gg.Id == gsid);
                        if (goerSupporter != null)
                        {
                            m.GoerId          = goerSupporter.GoerId; // suppoert this particular goer
                            m.GoerSupporterId = gsid;
                        }
                        else
                        {
                            m.GoerId = 0; // allow this supporter to still select a goer
                        }
                    }
                    else if (goerid.HasValue)
                    {
                        m.GoerId = goerid;
                    }
                }
            }
            if (Request.Url != null)
            {
                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(Message("invalid link"));
                }
                var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                if (ot == null)
                {
                    return(Message("invalid link"));
                }
#if DEBUG
#else
                if (ot.Used)
                {
                    return(Message("link used"));
                }
#endif
                if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                {
                    return(Message("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.UserPeopleId = pid;
                var existingRegistration = m.GetExistingRegistration(pid);
                if (existingRegistration != null)
                {
                    TempData["er"] = m.UserPeopleId;
                    return(Redirect("/OnlineReg/Existing/" + existingRegistration.DatumId));
                }
                OnlineRegPersonModel p = null;
                if (showfamily != true)
                {
                    p = m.LoadExistingPerson(pid, 0);
                    OnlineRegPersonModelValidator.ValidateModelForFind(p, ModelState, m, 0);
                    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));
                }
                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();
                    }
                    p.CheckSetFee();
                    m.HistoryAdd("index, pid={0}, !showfamily, p.org, found=true".Fmt(pid));
                    return(View(m));
                }
                m.HistoryAdd("index, pid=" + pid);
                return(View(m));
            }
            m.HistoryAdd("index");
            return(View(m));
        }
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            // Submit from AddressMaritalGenderForm
            fromMethod = "SubmitNew";
            ModelState.Clear();
            m.HistoryAdd("SubmitNew id=" + id);
            var p = m.List[id];
            if (p.ComputesOrganizationByAge())
                p.orgid = null; // forget any previous information about selected org, may have new information like gender
            p.ValidateModelForNew(ModelState, id);

            SetHeaders(m);
            var ret = p.AddNew(ModelState, id);
            return ret.HasValue()
                ? View(ret, m)
                : FlowList(m);
        }
Beispiel #41
0
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            ModelState.Clear();
            m.HistoryAdd("SubmitNew id=" + id);
            var p = m.List[id];

            OnlineRegPersonModelValidator.ValidateModelForNew(p, ModelState, id);

            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"));
        }
 public ActionResult PostDonation(OnlineRegModel m)
 {
     if (m.donor == null && m.donation > 0)
     {
         ModelState.AddModelError("donation", "Please indicate who is the donor");
         SetHeaders(m);
         return View("Other/AskDonation", m);
     }
     TempData["onlineregmodel"] = Util.Serialize(m);
     return Redirect("/OnlineReg/CompleteRegistration");
 }
Beispiel #43
0
        public ActionResult ApplyCoupon(PaymentForm pf)
        {
            OnlineRegModel m = null;

            if (pf.PayBalance == false)
            {
                m = OnlineRegModel.GetRegistrationFromDatum(pf.DatumId);
                if (m == null)
                {
                    return(Json(new { error = "coupon not find your registration" }));
                }
                m.ParseSettings();
            }

            if (!pf.Coupon.HasValue())
            {
                return(Json(new { error = "empty coupon" }));
            }
            var coupon      = pf.Coupon.ToUpper().Replace(" ", "");
            var admincoupon = DbUtil.Db.Setting("AdminCoupon", "ifj4ijweoij").ToUpper().Replace(" ", "");

            if (coupon == admincoupon)
            {
                if (pf.PayBalance)
                {
                    var tic = pf.CreateTransaction(DbUtil.Db, pf.AmtToPay);
                    return(Json(new { confirm = $"/onlinereg/ConfirmDuePaid/{tic.Id}?TransactionID=AdminCoupon&Amount={tic.Amt}" }));
                }
                else
                {
                    return(Json(new { confirm = $"/OnlineReg/Confirm/{pf.DatumId}?TransactionId=AdminCoupon" }));
                }
            }

            var c = DbUtil.Db.Coupons.SingleOrDefault(cp => cp.Id == coupon);

            if (c == null)
            {
                return(Json(new { error = "coupon not found" }));
            }

            if (pf.OrgId.HasValue && c.Organization != null && c.Organization.OrgPickList.HasValue())
            {
                var a = c.Organization.OrgPickList.SplitStr(",").Select(ss => ss.ToInt()).ToArray();
                if (!a.Contains(pf.OrgId.Value))
                {
                    return(Json(new { error = "coupon and org do not match" }));
                }
            }
            else if (pf.OrgId != c.OrgId)
            {
                return(Json(new { error = "coupon and org do not match" }));
            }
            if (c.Used.HasValue && c.Id.Length == 12)
            {
                return(Json(new { error = "coupon already used" }));
            }
            if (c.Canceled.HasValue)
            {
                return(Json(new { error = "coupon canceled" }));
            }

            var ti = pf.CreateTransaction(DbUtil.Db, Math.Min(c.Amount ?? 0m, pf.AmtToPay ?? 0m));

            if (m != null) // Start this transaction in the chain
            {
                m.HistoryAdd("ApplyCoupon");
                m.TranId = ti.OriginalId;
                m.UpdateDatum();
            }
            var tid = $"Coupon({Util.fmtcoupon(coupon):n2})";

            if (!pf.PayBalance)
            {
                OnlineRegModel.ConfirmDuePaidTransaction(ti, tid, false);
            }

            var msg = $"<i class='red'>Your coupon for {c.Amount:n2} has been applied, your balance is now {ti.Amtdue:n2}</i>.";

            if (ti.Amt < pf.AmtToPay)
            {
                msg += "You still must complete this transaction with a payment";
            }

            if (m != null)
            {
                m.UseCoupon(ti.TransactionId, ti.Amt ?? 0);
            }
            else
            {
                c.UseCoupon(ti.FirstTransactionPeopleId(), ti.Amt ?? 0);
            }
            DbUtil.Db.SubmitChanges();

            if (pf.PayBalance)
            {
                return(Json(new { confirm = $"/onlinereg/ConfirmDuePaid/{ti.Id}?TransactionID=Coupon({Util.fmtcoupon(coupon)})&Amount={ti.Amt}" }));
            }
            pf.AmtToPay -= ti.Amt;
            if (pf.AmtToPay <= 0)
            {
                return(Json(new { confirm = $"/OnlineReg/Confirm/{pf.DatumId}?TransactionId={"Coupon"}" }));
            }
            return(Json(new { tiamt = pf.AmtToPay, amtdue = ti.Amtdue, amt = pf.AmtToPay.ToString2("N2"), msg }));
        }
Beispiel #44
0
        public ActionResult ProcessPayment(PaymentForm pf)
        {
            if (pf.ProcessType == PaymentProcessTypes.EmpytProcess)
            {
                pf.ProcessType = PaymentProcessTypes.OnlineRegistration;
            }
            // One time or Reg...
            Response.NoCache();

#if DEBUG
#else
            if (Session["FormId"] != null)
            {
                if ((Guid)Session["FormId"] == pf.FormId)
                {
                    return(Message("Already submitted"));
                }
            }
#endif

            OnlineRegModel m  = null;
            var            ed = CurrentDatabase.RegistrationDatas.SingleOrDefault(e => e.Id == pf.DatumId);
            if (ed != null)
            {
                m = Util.DeSerialize <OnlineRegModel>(ed.Data);
            }

#if DEBUG
#else
            if (m != null && m.History.Any(h => h.Contains("ProcessPayment")))
            {
                return(Content("Already submitted"));
            }
#endif

            int?datumid = null;
            if (m != null)
            {
                m.TermsSignature = pf.TermsSignature;
                datumid          = m.DatumId;
                var msg = m.CheckDuplicateGift(pf.AmtToPay);
                if (Util.HasValue(msg))
                {
                    return(Message(msg));
                }
            }
            if (IsCardTester(pf, "Payment Page"))
            {
                return(Message("Found Card Tester"));
            }

            int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m?.ProcessType ?? pf.ProcessType);

            if (CurrentDatabase.Setting("UseRecaptcha") && GatewayId != (int)GatewayTypes.Pushpay)
            {
                if (!GoogleRecaptcha.IsValidResponse(HttpContext, CurrentDatabase))
                {
                    CurrentDatabase.LogActivity("OnlineReg Error ReCaptcha validation failed.", pf.OrgId, did: datumid);
                    ModelState.AddModelError("form", "ReCaptcha validation failed.");
                    return(View("Payment/Process", pf));
                }
            }

            RouteModel ret;

            if ((int)GatewayTypes.Pushpay == GatewayId)
            {
                int orgId;
                ret      = pf.ProcessExternalPayment(m, out orgId);
                pf.OrgId = orgId;
            }
            else
            {
                ret = pf.ProcessPayment(ModelState, m);
            }
            SetHeaders(pf.OrgId ?? 0);

            switch (ret.Route)
            {
            case RouteType.ModelAction:
                return(View(ret.View, ret.Model));

            case RouteType.AmtDue:
                ViewBag.amtdue = ret.AmtDue;
                return(View(ret.View, ret.Transaction));

            case RouteType.Error:
                CurrentDatabase.LogActivity("OnlineReg Error " + ret.Message, pf.OrgId, did: datumid);
                return(Message(ret.Message));

            case RouteType.ValidationError:
                return(View(ret.View, pf));

            default:     // unexptected Route
                if (ModelState.IsValid)
                {
                    ErrorSignal.FromCurrentContext().Raise(new Exception("OnlineReg Unexpected route datum= " + datumid));
                    CurrentDatabase.LogActivity("OnlineReg Unexpected Route " + ret.Message, oid: pf.OrgId, did: datumid);
                    ModelState.AddModelError("form", "unexpected error in payment processing");
                }
                return(View(ret.View ?? "Payment/Process", pf));
            }
        }
Beispiel #45
0
 public void SetHeaders(OnlineRegModel m2)
 {
     Session["gobackurl"] = m2.URL;
     ViewBag.Title        = m2.Header;
     SetHeaders2(m2.Orgid ?? m2.masterorgid ?? 0);
 }
Beispiel #46
0
        public ActionResult OnePageGiving(int id, bool?testing, string source)
        {
            Response.NoCache();
            try
            {
                var m = new OnlineRegModel(Request, CurrentDatabase, id, testing, null, null, source);

                var pid = Util.UserPeopleId;
                if (pid.HasValue)
                {
                    PrePopulate(m, pid.Value);
                }

                SetHeaders(m);
                m.CheckRegisterLink(null);

                if (m.NotActive())
                {
                    return(View("OnePageGiving/NotActive", m));
                }

                if ((m.org.IsMissionTrip.IsNotNull() && m.org.IsMissionTrip == true) ? true : false)
                {
                    m.ProcessType = PaymentProcessTypes.OneTimeGiving;
                }
                else
                {
                    m.ProcessType = (m.org.RegistrationTypeId.IsNull() || m.org.RegistrationTypeId == RegistrationTypeCode.OnlineGiving)
                        ? PaymentProcessTypes.OneTimeGiving
                        : PaymentProcessTypes.OnlineRegistration;
                }

                int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType);

                if (GatewayId == (int)GatewayTypes.Pushpay && m.OnlineGiving())
                {
                    ViewBag.Header = "One Page Giving";
                    if (string.IsNullOrEmpty(MultipleGatewayUtils.Setting(CurrentDatabase, "PushpayMerchant", "", (int)m.ProcessType)))
                    {
                        return(View("OnePageGiving/NotConfigured"));
                    }

                    return(Redirect($"/Pushpay/OnePage"));
                }

                var pf = PaymentForm.CreatePaymentForm(m);
                pf.AmtToPay = null;

                if (string.IsNullOrWhiteSpace(pf.Type))
                {
                    pf.Type = pf.NoCreditCardsAllowed ? "B" : "C";
                }

#if DEBUG
                if (!pid.HasValue)
                {
                    pf.First      = "Otis";
                    pf.Last       = "Sukamotis";
                    pf.Email      = "*****@*****.**";
                    pf.Address    = "135 Riveredge Cv";
                    pf.Zip        = "";
                    pf.CreditCard = "3111111111111111";
                    pf.Expires    = "1018";
                    pf.CVV        = "123";
                    pf.AmtToPay   = 23M;
                }
#endif

                var p = m.List[0];
                if (pf.ShowCampusOnePageGiving)
                {
                    pf.Campuses = p.Campuses().ToList();
                }

                var designatedFund = p.DesignatedDonationFund().FirstOrDefault();
                pf.Description = designatedFund != null ? designatedFund.Text : m.DescriptionForPayment;

                SetInstructions(m);

                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }
            catch (Exception ex)
            {
                if (ex is BadRegistrationException)
                {
                    return(Message(ex.Message));
                }
                throw;
            }
        }
Beispiel #47
0
 public ActionResult OnePageGivingLogin(int id, bool? testing, string source)
 {
     var m = new OnlineRegModel(Request, id, testing, null, null, source);
     SetHeaders(m);
     return View("OnePageGiving/Login", m);
 }
Beispiel #48
0
        public ActionResult OnePageGiving(PaymentForm pf, Dictionary <int, decimal?> fundItem)
        {
            // need save off the original amt to pay if there is an error later on.
            var amtToPay = pf.AmtToPay;

            var id = pf.OrgId;

            if (id == null)
            {
                return(Message("Missing OrgId"));
            }

            if (!Util.ValidEmail(pf.Email))
            {
                ModelState.AddModelError("Email", "Need a valid email address");
            }
            if (pf.IsUs && !pf.Zip.HasValue())
            {
                ModelState.AddModelError("Zip", "Zip is Required for US");
            }
            if (pf.ShowCampusOnePageGiving)
            {
                if ((pf.CampusId ?? 0) == 0)
                {
                    ModelState.AddModelError("CampusId", "Campus is Required");
                }
            }

            var m = new OnlineRegModel(Request, CurrentDatabase, pf.OrgId, pf.testing, null, null, pf.source)
            {
                URL = $"/OnePageGiving/{pf.OrgId}"
            };

            var pid = Util.UserPeopleId;

            if (pid.HasValue)
            {
                PrePopulate(m, pid.Value);
            }

            // we need to always retrieve the entire list of funds for one page giving calculations.
            m.List[0].RetrieveEntireFundList = true;

            // first re-build list of fund items with only ones that contain a value (amt).
            var fundItems = fundItem.Where(f => f.Value.GetValueOrDefault() > 0).ToDictionary(f => f.Key, f => f.Value);

            var designatedFund = m.settings[id.Value].DonationFundId ?? 0;

            if (designatedFund != 0)
            {
                fundItems.Add(designatedFund, pf.AmtToPay);
            }

            // set the fund items on online reg person if there are any.
            if (fundItems.Any())
            {
                m.List[0].FundItem = fundItems;
                pf.AmtToPay        = m.List[0].FundItemsChosen().Sum(f => f.Amt);
            }

            if (pf.AmtToPay.GetValueOrDefault() == 0)
            {
                ModelState.AddModelError("AmtToPay", "Invalid Amount");
            }

            SetHeaders(m);
            SetInstructions(m);

            var p = m.List[0];

            if (pf.ShowCampusOnePageGiving)
            {
                pf.Campuses = p.Campuses().ToList();
            }

            if (!ModelState.IsValid)
            {
                m.List[0].FundItem = fundItem;
                pf.AmtToPay        = amtToPay;
                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }

            if (CheckAddress(pf) == false)
            {
                m.List[0].FundItem = fundItem;
                pf.AmtToPay        = amtToPay;
                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }


            if (!ModelState.IsValid)
            {
                m.List[0].FundItem = fundItem;
                pf.AmtToPay        = amtToPay;
                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }

            p.orgid          = m.Orgid;
            p.FirstName      = pf.First;
            p.LastName       = pf.Last;
            p.EmailAddress   = pf.Email;
            p.Phone          = pf.Phone;
            p.AddressLineOne = pf.Address;
            p.City           = pf.City;
            p.State          = pf.State;
            p.ZipCode        = pf.Zip;
            p.Country        = pf.Country;
            if (pf.ShowCampusOnePageGiving)
            {
                p.Campus = pf.CampusId.ToString();
            }

            p.IsNew = p.person == null;

            if (pf.testing)
            {
                pf.CheckTesting();
            }

            if (pf.Country.HasValue() && !pf.Zip.HasValue())
            {
                pf.Zip = "NA";
            }

            pf.ValidatePaymentForm(ModelState, false);
            if (!ModelState.IsValid)
            {
                m.List[0].FundItem = fundItem;
                pf.AmtToPay        = amtToPay;
                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }


            if (m?.UserPeopleId != null && m.UserPeopleId > 0)
            {
                pf.CheckStoreInVault(ModelState, m.UserPeopleId.Value);
            }
            if (!ModelState.IsValid)
            {
                m.List[0].FundItem = fundItem;
                pf.AmtToPay        = amtToPay;
                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }

            if (CurrentDatabase.Setting("UseRecaptcha"))
            {
                if (!GoogleRecaptcha.IsValidResponse(HttpContext, CurrentDatabase))
                {
                    m.List[0].FundItem = fundItem;
                    pf.AmtToPay        = amtToPay;
                    ModelState.AddModelError("TranId", "ReCaptcha validation failed.");
                    return(View("OnePageGiving/Index", new OnePageGivingModel {
                        OnlineRegPersonModel = m.List[0],
                        PaymentForm = pf
                    }));
                }
            }

            var ti = pf.ProcessPaymentTransaction(m);

            if ((ti.Approved ?? false) == false)
            {
                ModelState.AddModelError("TranId", ti.Message);

                m.List[0].FundItem = fundItem;
                pf.AmtToPay        = amtToPay;
                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
            }
            if (pf.Zip == "NA")
            {
                pf.Zip = null;
            }

            var ret = m.ConfirmTransaction(ti);

            switch (ret.Route)
            {
            case RouteType.ModelAction:
                if (ti.Approved == true)
                {
                    var url = $"/OnePageGiving/ThankYou/{id}{(pf.testing ? $"?testing=true&source={pf.source}" : $"?source={pf.source}")}";
                    return(Redirect(url));
                }
                ErrorSignal.FromCurrentContext().Raise(new Exception(ti.Message));
                ModelState.AddModelError("TranId", ti.Message);

                m.List[0].FundItem = fundItem;
                pf.AmtToPay        = amtToPay;
                return(View("OnePageGiving/Index", new OnePageGivingModel()
                {
                    OnlineRegPersonModel = m.List[0], PaymentForm = pf
                }));
 public ActionResult SubmitQuestions(int id, OnlineRegModel m)
 {
     fromMethod = "SubmitQuestions";
     m.HistoryAdd("SubmitQuestions 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].ValidateModelQuestions(ModelState, id);
     return FlowList(m);
 }
        public ActionResult RegisterFamilyMember(int id, OnlineRegModel m)
        {
            // got here by clicking on a link in the Family list
            fromMethod = "Register";

            m.StartRegistrationForFamilyMember(id, ModelState);

            // show errors or take them to the Questions page
            return FlowList(m);
        }
Beispiel #51
0
        public ActionResult OnePageGiving(PaymentForm pf)
        {
            if (!Util.ValidEmail(pf.Email))
                ModelState.AddModelError("Email", "Need a valid email address");
            if (pf.AmtToPay == 0)
                ModelState.AddModelError("AmtToPay", "Invalid Amount");
            if (pf.IsUs && !pf.Zip.HasValue())
                ModelState.AddModelError("Zip", "Zip is Required for US");
            if(pf.ShowCampusOnePageGiving)
                if((pf.CampusId ?? 0) == 0)
                    ModelState.AddModelError("CampusId", "Campus is Required");

            var m = new OnlineRegModel(Request, pf.OrgId, pf.testing, null, null, pf.source)
                { URL = "/OnePageGiving/" + pf.OrgId};
            SetHeaders(m);
            SetInstructions(m);
            var p = m.List[0];
            if(pf.ShowCampusOnePageGiving)
                pf.Campuses = p.Campuses().ToList();

            if (!ModelState.IsValid)
                return View("OnePageGiving/Index", pf);

            if (CheckAddress(pf) == false)
                return View("OnePageGiving/Index", pf);

            pf.ValidatePaymentForm(ModelState, shouldValidateBilling: false);
            if (!ModelState.IsValid)
                return View("OnePageGiving/Index", pf);

            p.orgid = m.Orgid;
            p.FirstName = pf.First;
            p.LastName = pf.Last;
            p.EmailAddress = pf.Email;
            p.Phone = pf.Phone;
            p.AddressLineOne = pf.Address;
            p.City = pf.City;
            p.State = pf.State;
            p.ZipCode = pf.Zip;
            p.Country = pf.Country;
            if(pf.ShowCampusOnePageGiving)
                p.Campus = pf.CampusId.ToString();
            pf.State = pf.State;

            p.IsNew = p.person == null;

            if (pf.testing)
                pf.CheckTesting();
            var id = pf.OrgId;
            if(id == null)
                return Message("Missing OrgId");
            if (pf.Country.HasValue() && !pf.Zip.HasValue())
                pf.Zip = "NA";
            var ti = pf.ProcessPaymentTransaction(m);
            if ((ti.Approved ?? false) == false)
            {
                ModelState.AddModelError("TranId", ti.Message);
                return View("OnePageGiving/Index", pf);
            }
            if (pf.Zip == "NA")
                pf.Zip = null;
            var fundid = m.settings[id.Value].DonationFundId ?? 0;
            p.FundItem.Add(fundid, pf.AmtToPay);
            var ret = m.ConfirmTransaction(ti);
            switch (ret.Route)
            {
                case RouteType.ModelAction:
                    if (ti.Approved == true)
                    {
                        TempData["onlineregmodel"] = Util.Serialize(m);
                        return Redirect("/OnePageGiving/ThankYou");
                    }
                    ErrorSignal.FromCurrentContext().Raise(new Exception(ti.Message));
                    ModelState.AddModelError("TranId", ti.Message);
                    return View("OnePageGiving/Index", pf);
                case RouteType.Error:
                    DbUtil.Db.LogActivity("OnePageGiving Error " + ret.Message, pf.OrgId);
                    return Message(ret.Message);
                default: // unexptected Route
                    ErrorSignal.FromCurrentContext().Raise(new Exception("OnePageGiving Unexpected route"));
                    DbUtil.Db.LogActivity("OnlineReg Unexpected Route " + ret.Message, pf.OrgId);
                    ModelState.AddModelError("TranId", "unexpected error in payment processing");
                    return View(ret.View ?? "OnePageGiving/Index", pf);
            }
        }
        private ActionResult ErrorResult(OnlineRegModel m, Exception ex, string errorDisplay)
        {
            // ReSharper disable once EmptyGeneralCatchClause
            try
            {
                m.UpdateDatum();
            }
            catch
            {
            }

            var ex2 = new Exception($"{errorDisplay}, {DbUtil.Db.ServerLink("/OnlineReg/RegPeople/") + m.DatumId}", ex);
            ErrorSignal.FromCurrentContext().Raise(ex2);
            m.Log(ex2.Message);
            TempData["error"] = errorDisplay;
            TempData["stack"] = ex.StackTrace;
            return Content("/Error/");
        }