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; if (m.Orgid == Util.CreateAccountCode) { return(Content("/Person2/" + Util.UserPeopleId)); } var existingRegistration = m.GetExistingRegistration(Util.UserPeopleId ?? 0); if (existingRegistration != null) { TempData["er"] = m.UserPeopleId = Util.UserPeopleId; return(Content("/OnlineReg/Existing/" + existingRegistration.DatumId)); } Debug.Assert(Util.UserPeopleId != null, "Util.UserPeopleId != null"); m.CreateList(); m.UserPeopleId = Util.UserPeopleId; 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.OnlineGiving()) { return(Register(Util.UserPeopleId.Value, m)); } if (m.UserSelectsOrganization()) { OnlineRegPersonModelValidator.ValidateModelForFind(m.List[0], ModelState, m, 0); } m.List[0].LoggedIn = true; m.HistoryAdd("login"); return(FlowList(m, "Login")); }
private string RouteManageGivingSubscriptionsPledgeVolunteer(OnlineRegModel m) { Util.TempPeopleId = m.UserPeopleId ?? CurrentDatabase.UserPeopleId; if (m.RegisterLinkMaster()) { if (m.registerLinkType.HasValue()) { if (m.registerLinkType.StartsWith("registerlink") || m.registerLinkType == "masterlink" || User.Identity.IsAuthenticated) { Util.SetValueInSession("token", m.registertag); } } return($"/OnlineReg/RegisterLinkMaster/{m.Orgid}"); } if (m.ManagingSubscriptions()) { return($"/OnlineReg/ManageSubscriptions/{m.masterorgid}"); } if (m.ManageGiving()) { return($"/OnlineReg/ManageGiving/{m.Orgid}"); } if (m.OnlinePledge()) { return($"/OnlineReg/ManagePledge/{m.Orgid}"); } if (m.ChoosingSlots()) { return($"/OnlineReg/ManageVolunteer/{m.Orgid}"); } return(null); }
private string RouteManageGivingSubscriptionsPledgeVolunteer(OnlineRegModel m) { if (m.RegisterLinkMaster()) { if (m.registerLinkType.HasValue()) { if (m.registerLinkType.StartsWith("registerlink") || m.registerLinkType == "masterlink" || User.Identity.IsAuthenticated) { TempData["token"] = m.registertag; TempData["PeopleId"] = m.UserPeopleId ?? Util.UserPeopleId; } } return($"/OnlineReg/RegisterLinkMaster/{m.Orgid}"); } TempData["PeopleId"] = m.UserPeopleId ?? Util.UserPeopleId; if (m.ManagingSubscriptions()) { return($"/OnlineReg/ManageSubscriptions/{m.masterorgid}"); } if (m.ManageGiving()) { return($"/OnlineReg/ManageGiving/{m.Orgid}"); } if (m.OnlinePledge()) { return($"/OnlineReg/ManagePledge/{m.Orgid}"); } if (m.ChoosingSlots()) { return($"/OnlineReg/ManageVolunteer/{m.Orgid}"); } TempData.Remove("PeopleId"); return(null); }
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; if (m.masterorgid.HasValue && m.masterorg.RegistrationTypeId == RegistrationTypeCode.ManageSubscriptions2) { return(Content("/OnlineReg/ManageSubscriptions/{0}".Fmt(m.masterorgid))); } return(Content("/OnlineReg/ManageSubscriptions/{0}".Fmt(m.divid))); } 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; return(FlowList(m, "Login")); }
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, CurrentDatabase, id, testing, email, login, source); if (m.ManageGiving()) { Session["Campus"] = Request.QueryString["campus"]; Session["DefaultFunds"] = Request.QueryString["funds"]; m.Campus = Session["Campus"]?.ToString(); m.DefaultFunds = Session["DefaultFunds"]?.ToString(); } if (m.org != null && m.org.IsMissionTrip == true) { if (gsid != null || goerid != null) { m.PrepareMissionTrip(gsid, goerid); } } SetHeaders(m); var pid = m.CheckRegisterLink(registertag); if (m.NotActive()) { return(View("OnePageGiving/NotActive", m)); } if (m.MissionTripSelfSupportPaylink.HasValue() && m.GoerId > 0) { return(Redirect(m.MissionTripSelfSupportPaylink)); } return(RouteRegistration(m, pid, showfamily)); } catch (Exception ex) { if (ex is BadRegistrationException) { return(Message(ex.Message)); } throw; } }
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")); }
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 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")); }
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)); }
public ActionResult Index(int?id, bool?testing, string email, bool?login, string registertag, bool?showfamily, int?goerid, int?gsid, string source, int?pledgeFund) { Response.NoCache(); var m = new OnlineRegModel(Request, CurrentDatabase, id, testing, email, login, source); var isMissionTrip = (m.org?.IsMissionTrip).GetValueOrDefault(); if (isMissionTrip) { m.ProcessType = PaymentProcessTypes.OnlineRegistration; } else { AssignPaymentProcessType(ref m); } if (pledgeFund != null) { m.pledgeFundId = pledgeFund.Value; } SetHeaders(m); int?GatewayId = MultipleGatewayUtils.GatewayId(CurrentDatabase, m.ProcessType); var gatewayRequired = (m.PayAmount() > 0 || m.ProcessType == PaymentProcessTypes.OneTimeGiving || m.ProcessType == PaymentProcessTypes.RecurringGiving); if (GatewayId.IsNull() && gatewayRequired) { return(View("OnePageGiving/NotConfigured")); } if ((int)GatewayTypes.Pushpay == GatewayId && string.IsNullOrEmpty(MultipleGatewayUtils.Setting(CurrentDatabase, "PushpayMerchant", "", (int)m.ProcessType))) { ViewBag.Header = m.Header; ViewBag.Instructions = m.Instructions; return(View("OnePageGiving/NotConfigured")); } if (m.ManageGiving()) { Session[$"Campus-{m.Orgid}"] = m.Campus = Request.QueryString["campus"]; Session["DefaultFunds"] = Request.QueryString["funds"]; m.DefaultFunds = Session["DefaultFunds"]?.ToString(); } if (isMissionTrip) { if (gsid != null || goerid != null) { m.PrepareMissionTrip(gsid, goerid); } } var pid = m.CheckRegisterLink(registertag); if (m.NotActive()) { return(View("OnePageGiving/NotActive", m)); } if (m.MissionTripSelfSupportPaylink.HasValue() && m.GoerId > 0) { return(Redirect(m.MissionTripSelfSupportPaylink)); } return(RouteRegistration(m, pid, showfamily)); }
private ConfirmEnum ConfirmTransaction(OnlineRegModel m, string TransactionID) { m.ParseSettings(); if (m.List.Count == 0) { throw new Exception(" unexpected, no registrants found in confirmation"); } var ret = ConfirmEnum.Confirm; var managingsubs = m.ManagingSubscriptions(); var choosingslots = m.ChoosingSlots(); var t = m.Transaction; if (t == null && !managingsubs && !choosingslots) { m.History.Add("ConfirmTransaction"); m.UpdateDatum(completed: true); var pf = PaymentForm.CreatePaymentForm(m); t = pf.CreateTransaction(DbUtil.Db); m.TranId = t.Id; } if (t != null) { ViewBag.message = t.Message; } if (m.org != null && m.org.RegistrationTypeId == RegistrationTypeCode.CreateAccount) { m.List[0].CreateAccount(); ret = ConfirmEnum.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, tranid: t.Id); } } t.TransactionPeople.Add(new TransactionPerson { PeopleId = p.person.PeopleId, Amt = t.Amt, OrgId = m.Orgid, }); 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 ?? 0, p.setting.DonationFundId, desc, tranid: t.Id); } 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(); ret = ConfirmEnum.ConfirmAccount; } else if (choosingslots) { m.ConfirmPickSlots(); m.URL = null; ViewBag.ManagingVolunteer = true; ViewBag.CreatedAccount = m.List[0].CreatingAccount; ret = ConfirmEnum.ConfirmAccount; } else if (m.OnlinePledge()) { m.SendLinkForPledge(); ViewBag.CreatedAccount = m.List[0].CreatingAccount; ret = ConfirmEnum.ConfirmAccount; } else if (m.ManageGiving()) { m.SendLinkToManageGiving(); ret = ConfirmEnum.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(); throw new Exception("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(); throw new Exception("no person"); } m.UseCoupon(t.TransactionId, t.Amt ?? 0); } if (m.IsCreateAccount() || m.ManagingSubscriptions()) { m.email = m.List[0].person.EmailAddress; } else { m.email = m.List[0].EmailAddress; } ViewBag.email = m.email; if (m.masterorgid.HasValue && m.Orgid.HasValue && !m.settings[m.Orgid.Value].Subject.HasValue()) { ViewBag.orgname = m.masterorg.OrganizationName; } else { ViewBag.orgname = m.org != null ? m.org.OrganizationName : m.masterorg.OrganizationName; } LogOutOfOnlineReg(); return(ret); }