Example #1
0
        public ActionResult Login(OnlineRegModel m)
        {
            var ret = AccountModel.AuthenticateLogon(m.username, m.password, Session, Request);

            if (ret is string)
            {
                ModelState.AddModelError("authentication", ret.ToString());
                return(FlowList(m, "Login"));
            }
            Session["OnlineRegLogin"] = true;
            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"));
        }
Example #2
0
        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"));
        }
Example #3
0
        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"));
        }
Example #4
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"));
        }
Example #5
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));
        }