public ActionResult AddAnotherPerson(OnlineRegModel m) { m.HistoryAdd("AddAnotherPerson"); m.ParseSettings(); if (!ModelState.IsValid) { return(FlowList(m, "AddAnotherPerson")); } #if DEBUG2 m.List.Add(new OnlineRegPersonModel { guid = Guid.NewGuid(), divid = m.divid, orgid = m.orgid, masterorgid = m.masterorgid, first = "Bethany", last = "Carroll", //bmon = 1, //bday = 29, //byear = 1987, dob = "1/29/87", email = "*****@*****.**", phone = "9017581862".FmtFone(), LoggedIn = m.UserPeopleId.HasValue, }); #else m.List.Add(new OnlineRegPersonModel { orgid = m.Orgid, masterorgid = m.masterorgid, LoggedIn = m.UserPeopleId.HasValue, }); #endif return(FlowList(m, "AddAnotherPerson")); }
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")); }
public ActionResult SubmitNew(int id, OnlineRegModel m) { // Submit from AddressMaritalGenderForm var msg = m.CheckExpiredOrCompleted(); if (msg.HasValue()) { return(PageMessage(msg)); } 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)); }
public ActionResult SaveProgress(OnlineRegModel m) { m.HistoryAdd("saveprogress"); if (m.UserPeopleId == null) { m.UserPeopleId = Util.UserPeopleId; } m.UpdateDatum(); var p = m.UserPeopleId.HasValue ? DbUtil.Db.LoadPersonById(m.UserPeopleId.Value) : m.List[0].person; if (p == null) { return(Content("We have not found your record yet, cannot save progress, sorry")); } if (m.masterorgid == null && m.Orgid == null) { return(Content("Registration is not far enough along to save, sorry.")); } var registerLink = EmailReplacements.CreateRegisterLink(m.masterorgid ?? m.Orgid, "Resume registration for {0}".Fmt(m.Header)); var msg = "<p>Hi {first},</p>\n<p>Here is the link to continue your registration:</p>\n" + registerLink; var notifyids = DbUtil.Db.NotifyIds((m.masterorgid ?? m.Orgid).Value, (m.masterorg ?? m.org).NotifyIds); DbUtil.Db.Email(notifyids[0].FromEmail, p, "Continue your registration for {0}".Fmt(m.Header), msg); /* We use Content as an ActionResult instead of Message because we want plain text sent back * This is an HttpPost ajax call and will have a SiteLayout wrapping this. */ return(Content("We have saved your progress. An email with a link to finish this registration will come to you shortly.")); }
public ActionResult Login(OnlineRegModel m) { fromMethod = "Login"; 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 NoLogin(OnlineRegModel m) { m.nologin = true; m.CreateList(); m.HistoryAdd("nologin"); return(FlowList(m, "NoLogin")); }
public ActionResult Login(OnlineRegModel m) { fromMethod = "Login"; var ret = AccountModel.AuthenticateLogon(m.username, m.password, Session, Request, CurrentDatabase, CurrentImageDatabase); 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"); if (m.org != null && m.org.IsMissionTrip == true && m.SupportMissionTrip) { PrepareFirstRegistrant(ref m, m.UserPeopleId.Value, false, out OnlineRegPersonModel p); } return(FlowList(m)); }
public ActionResult ShowMoreInfo(int id, OnlineRegModel m) { m.HistoryAdd("ShowMoreInfo id=" + id); DbUtil.Db.SetNoLock(); var p = m.List[id]; OnlineRegPersonModelValidator.ValidateModelForFind(p, ModelState, m, id); if (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[id].DateOfBirth), "Sorry, but registration is closed."); } if (p.Found == true) { p.FillPriorInfo(); } return(FlowList(m, "ShowMoreInfo")); } if (!p.whatfamily.HasValue && (id > 0 || p.LoggedIn == true)) { ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].whatfamily), "Choose a family option"); return(FlowList(m, "ShowMoreInfo")); } switch (p.whatfamily) { case 1: var u = DbUtil.Db.LoadPersonById(m.UserPeopleId.Value); p.AddressLineOne = u.PrimaryAddress; p.City = u.PrimaryCity; p.State = u.PrimaryState; p.ZipCode = u.PrimaryZip.FmtZip(); break; case 2: var pb = m.List[id - 1]; p.AddressLineOne = pb.AddressLineOne; p.City = pb.City; p.State = pb.State; p.ZipCode = pb.ZipCode; break; default: #if DEBUG p.AddressLineOne = "235 Riveredge Cv."; p.City = "Cordova"; p.State = "TN"; p.ZipCode = "38018"; p.gender = 1; p.married = 10; p.HomePhone = "9017581862"; #endif break; } p.ShowAddress = true; return(FlowList(m, "ShowMoreInfo")); }
public ActionResult FindRecord(int id, OnlineRegModel m) { // Anonymous person clicks submit to find their record var msg = m.CheckExpiredOrCompleted(); if (msg.HasValue()) { return(PageMessage(msg)); } fromMethod = "FindRecord"; m.HistoryAdd("FindRecord id=" + id); if (id >= m.List.Count) { return(FlowList(m)); } var p = m.GetFreshFindInfo(id); if (p.NeedsToChooseClass()) { p.RegistrantProblem = "Please Make Selection Above"; return(FlowList(m)); } p.ValidateModelForFind(ModelState, id); if (!ModelState.IsValid) { return(FlowList(m)); } if (p.AnonymousReRegistrant()) { return(View("Continue/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)); }
public ActionResult YesLogin(OnlineRegModel m) { m.HistoryAdd("yeslogin"); m.nologin = false; m.List = new List <OnlineRegPersonModel>(); #if DEBUG m.username = "******"; #endif return(FlowList(m, "NoLogin")); }
public ActionResult SubmitOtherInfo(int id, OnlineRegModel m) { m.HistoryAdd("SubmitOtherInfo id=" + id); if (m.List.Count <= id) { return(Content("<p style='color:red'>error: cannot find person on submit other info</p>")); } OnlineRegPersonModelValidator.ValidateModelForOther(m.List[id], ModelState, id); return(FlowList(m, "SubmitOtherInfo")); }
public ActionResult AskDonation(OnlineRegModel m) { m.HistoryAdd("AskDonation"); if (m.List.Count == 0) { return(Content("Can't find any registrants")); } RemoveLastRegistrantIfEmpty(m); SetHeaders(m); return(View(m)); }
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 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 Login(OnlineRegModel m) { fromMethod = "Login"; var ret = AccountModel.AuthenticateLogon(m.username, m.password, Session, Request, CurrentDatabase, CurrentImageDatabase); if (ret.ErrorMessage.HasValue()) { ModelState.AddModelError("authentication", ret.ErrorMessage); return(FlowList(m)); } else if (MembershipService.ShouldPromptForTwoFactorAuthentication(ret.User, CurrentDatabase, Request)) { Session[AccountController.MFAUserId] = ret.User.UserId; ViewData["hasshell"] = true; var orgId = m.Orgid ?? m.masterorgid; return(View("Auth", new AccountInfo { UsernameOrEmail = ret.User.Username, ReturnUrl = RouteExistingRegistration(m) ?? $"/OnlineReg/{orgId}" })); } else { AccountModel.FinishLogin(ret.User.Username, Session, CurrentDatabase, CurrentImageDatabase); if (ret.User.UserId.Equals(Session[AccountController.MFAUserId])) { MembershipService.SaveTwoFactorAuthenticationToken(CurrentDatabase, Response); Session.Remove(AccountController.MFAUserId); } } 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"); if (m.org != null && m.org.IsMissionTrip == true && m.SupportMissionTrip) { PrepareFirstRegistrant(ref m, m.UserPeopleId.Value, false, out OnlineRegPersonModel p); } return(FlowList(m)); }
public ActionResult Register(int id, OnlineRegModel m) { ModelState.Clear(); m.HistoryAdd("Register"); int index = m.List.Count - 1; if (m.List[index].classid.HasValue) { m.classid = m.List[index].classid; } var p = m.LoadExistingPerson(id, index); OnlineRegPersonModelValidator.ValidateModelForFind(p, ModelState, m, id, selectFromFamily: true); if (!ModelState.IsValid) { return(FlowList(m, "Register")); } m.List[index] = p; if (p.ManageSubscriptions() && p.Found == true) { //p.OtherOK = true; return(FlowList(m, "Register")); } if (p.org != null && p.Found == true) { p.IsFilled = p.org.RegLimitCount(DbUtil.Db) >= p.org.Limit; if (p.IsFilled) { ModelState.AddModelError(m.GetNameFor(mm => mm.List[m.List.IndexOf(p)].Found), "Sorry, but registration is filled."); } if (p.Found == true) { p.FillPriorInfo(); } //if (!p.AnyOtherInfo()) //p.OtherOK = true; return(FlowList(m, "Register")); } if (p.org == null && p.ComputesOrganizationByAge()) { ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].Found), p.NoAppropriateOrgError); } if (p.ShowDisplay() && p.org != null && p.ComputesOrganizationByAge()) { p.classid = p.org.OrganizationId; } return(FlowList(m, "Register")); }
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 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)); }
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>")); } m.List[id].ValidateModelQuestions(ModelState, id); return(FlowList(m)); }
public ActionResult SaveProgress(OnlineRegModel m) { m.HistoryAdd("saveprogress"); if (m.UserPeopleId == null) { m.UserPeopleId = Util.UserPeopleId; } m.UpdateDatum(); var p = m.UserPeopleId.HasValue ? CurrentDatabase.LoadPersonById(m.UserPeopleId.Value) : m.List[0].person; if (p == null) { return(Content("We have not found your record yet, cannot save progress, sorry")); } if (m.masterorgid == null && m.Orgid == null) { return(Content("Registration is not far enough along to save, sorry.")); } var msg = CurrentDatabase.ContentHtml("ContinueRegistrationLink", @" <p>Hi {first},</p> <p>Here is the link to continue your registration:</p> Resume [registration for {orgname}] ").Replace("{orgname}", m.Header); var linktext = Regex.Match(msg, @"(\[(.*)\])", RegexOptions.Singleline).Groups[2].Value; var registerlink = EmailReplacements.CreateRegisterLink(m.masterorgid ?? m.Orgid, linktext); msg = Regex.Replace(msg, @"(\[.*\])", registerlink, RegexOptions.Singleline); var notifyids = CurrentDatabase.NotifyIds((m.masterorg ?? m.org).NotifyIds); CurrentDatabase.Email(notifyids[0].FromEmail, p, $"Continue your registration for {m.Header}", msg); /* We use Content as an ActionResult instead of Message because we want plain text sent back * This is an HttpPost ajax call and will have a SiteLayout wrapping this. */ return(Content(@" We have saved your progress. An email with a link to finish this registration will come to you shortly. <input type='hidden' id='SavedProgress' value='true'/> ")); }
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)); }
public ActionResult Cancel(int id, OnlineRegModel m) { m.HistoryAdd("Cancel id=" + id); m.List.RemoveAt(id); if (m.List.Count == 0) { m.List.Add(new OnlineRegPersonModel { orgid = m.Orgid, masterorgid = m.masterorgid, LoggedIn = m.UserPeopleId.HasValue, #if DEBUG FirstName = "Another", LastName = "Child", DateOfBirth = "12/1/02", EmailAddress = "*****@*****.**", #endif }); } return(FlowList(m, "Cancel")); }
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)); }
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)); }
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 })); }
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)); }
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) { 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 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")); }
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)); }