Example #1
0
 public ActionResult ShowMoreInfo(int id, OnlineRegModel m)
 {
     m.History.Add("ShowMoreInfo id=" + id);
     DbUtil.Db.SetNoLock();
     var p = m.List[id];
     p.ValidateModelForFind(ModelState, m);
     if (p.org != null && p.Found == true)
     {
         p.IsFilled = p.org.OrganizationMembers.Count() >= p.org.Limit;
         if (p.IsFilled)
             ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].dob), "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.address = u.PrimaryAddress;
             p.city = u.PrimaryCity;
             p.state = u.PrimaryState;
             p.zip = u.PrimaryZip.FmtZip();
             break;
         case 2:
             var pb = m.List[id - 1];
             p.address = pb.address;
             p.city = pb.city;
             p.state = pb.state;
             p.zip = pb.zip;
             break;
         default:
     #if DEBUG
             p.address = "235 Riveredge Cv.";
             p.city = "Cordova";
             p.state = "TN";
             p.zip = "38018";
             p.gender = 1;
             p.married = 10;
             p.homephone = "9017581862";
     #endif
             break;
     }
     p.ShowAddress = true;
     return FlowList(m, "ShowMoreInfo");
 }
Example #2
0
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            m.History.Add("SubmitNew id=" + id);
            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;
                    ViewData["orgname"] = m.masterorg.OrganizationName;
                    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");
        }
Example #3
0
 public ActionResult Register(int id, OnlineRegModel m)
 {
     m.History.Add("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);
     p.ValidateModelForFind(ModelState, m, 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.OrganizationMembers.Count() >= p.org.Limit;
         if (p.IsFilled)
             ModelState.AddModelError(m.GetNameFor(mm => mm.List[m.List.IndexOf(p)].Found), "Sorry, but registration is closed.");
         if (p.Found == true)
             p.FillPriorInfo();
         //if (!p.AnyOtherInfo())
         //p.OtherOK = true;
         return FlowList(m, "Register");
     }
     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.History.Add("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;
            p.ValidateModelForFind(ModelState, m);
            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();
                        ViewData["email"] = m.List[0].person.EmailAddress;
                        ViewData["orgname"] = m.org.OrganizationName;
                        ViewData["timeout"] = INT_timeout;
                        return View("ConfirmReregister");
                    }
                }
            }
            if (p.ManageSubscriptions()
                 || p.OnlinePledge()
                 || p.ManageGiving()
                 || m.ChoosingSlots())
            {
                p.OtherOK = true;
            }
            else if (p.org != null)
            {
                p.IsFilled = p.org.OrganizationMembers.Count() >= p.org.Limit;
                if (p.IsFilled)
                    ModelState.AddModelError(m.GetNameFor(mm => mm.List[id].dob), "Sorry, but registration is closed.");
                if (p.Found == true)
                    p.FillPriorInfo();
            }
            if (p.org != null && p.ShowDisplay() && p.ComputesOrganizationByAge())
                p.classid = p.org.OrganizationId;

            CheckSetFee(m, p);

            return FlowList(m, "PersonFind");
        }
Example #5
0
        // Main page
        public ActionResult Index(int? id, bool? testing, int? o, int? d, string email, bool? nologin, bool? login, string registertag, bool? showfamily)
        {
            #if DEBUG
            var om = DbUtil.Db.OrganizationMembers.SingleOrDefault(mm => mm.OrganizationId == 89469 && mm.PeopleId == 828612);
            if (om != null)
            {
                om.Drop(DbUtil.Db, false);
                DbUtil.Db.SubmitChanges();
            }
            #endif
            if (DbUtil.Db.Roles.Any(rr => rr.RoleName == "disabled"))
                return Content("Site is disabled for maintenance, check back later");
            Util.NoCache(Response);
            if (!id.HasValue)
                return Content("no organization");
            var m = new OnlineRegModel { orgid = id };
            if (m.org == null && m.masterorg == null)
                return Content("invalid registration");

            if (m.masterorg != null)
            {
                if (!OnlineRegModel.UserSelectClasses(m.masterorg).Any())
                    return Content("no classes available on this org");
            }
            else if (m.org != null)
            {
                if ((m.org.RegistrationTypeId ?? 0) == RegistrationTypeCode.None)
                    return Content("no registration allowed on this org");
            }
            m.URL = Request.Url.OriginalString;

            SetHeaders(m);

            #if DEBUG
            m.username = "******";
            m.testing = true;
            #else
            m.testing = testing;
            #endif
            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].email = email;

            var pid = 0;
            if (registertag.HasValue())
            {
                var guid = registertag.ToGuid();
                if (guid == null)
                    return Content("invalid link");
                var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                if (ot == null)
                    return Content("invalid link");
            #if DEBUG
            #else
                if (ot.Used)
                    return Content("link used");
            #endif
                if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                    return Content("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.List = new List<OnlineRegPersonModel>();
                m.UserPeopleId = pid;
                OnlineRegPersonModel p = null;
                if (showfamily != true)
                {
                    p = m.LoadExistingPerson(pid, 0);
                    p.ValidateModelForFind(ModelState, m);
                    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 Redirect("/OnlineReg/ManageGiving/{0}".Fmt(m.orgid));
                }
                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.OrganizationMembers.Count() >= 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();
                    CheckSetFee(m, p);
                    m.History.Add("index, pid={0}, !showfamily, p.org, found=true".Fmt(pid));
                    return View(m);
                }
                m.History.Add("index, pid=" + pid);
                return View(m);
            }
            m.History.Add("index");
            return View(m);
        }
Example #6
0
        public ActionResult SubmitNew(int id, OnlineRegModel m)
        {
            ModelState.Clear();
            m.History.Add("SubmitNew id=" + id);
            var p = m.List[id];
            p.ValidateModelForNew(ModelState);

            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");
        }
Example #7
0
        public ActionResult Index(int? id, bool? testing, string email, bool? nologin, bool? login, string registertag, bool? showfamily, int? goerid, int? gsid)
        {
            //            if (Util.IsDebug())
            //            {
            //                var q = from om in DbUtil.Db.OrganizationMembers
            //                    where om.OrganizationId == 89924
            //                    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");
            Util.NoCache(Response);
            if (!id.HasValue)
                return Content("no organization");
            var m = new OnlineRegModel { Orgid = id };
            if (m.org == null && m.masterorg == null)
                return Content("invalid registration");

            if (m.masterorg != null)
            {
                if (!OnlineRegModel.UserSelectClasses(m.masterorg).Any())
                    return Content("no classes available on this org");
            }
            else if (m.org != null)
            {
                if ((m.org.RegistrationTypeId ?? 0) == RegistrationTypeCode.None)
                    return Content("no registration allowed on this org");
                if (m.org.IsMissionTrip == true)
                {
                    if (gsid.HasValue)
                    {
                        var gs = DbUtil.Db.GoerSupporters.Single(gg => gg.Id == gsid);
                        m.GoerId = gs.GoerId;
                        m.GoerSupporterId = gsid;
                    }
                    else if (goerid.HasValue)
                    {
                        m.GoerId = goerid;
                    }
                }
            }
            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 Content("invalid link");
                var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                if (ot == null)
                    return Content("invalid link");
            #if DEBUG
            #else
                if (ot.Used)
                    return Content("link used");
            #endif
                if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                    return Content("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.List = new List<OnlineRegPersonModel>();
                m.UserPeopleId = pid;
                OnlineRegPersonModel p = null;
                if (showfamily != true)
                {
                    p = m.LoadExistingPerson(pid, 0);
                    p.ValidateModelForFind(ModelState, m);
                    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);
                    //return Redirect("/OnlineReg/ManageGiving/{0}".Fmt(m.Orgid));
                }
                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();
                    CheckSetFee(m, p);
                    m.History.Add("index, pid={0}, !showfamily, p.org, found=true".Fmt(pid));
                    return View(m);
                }
                m.History.Add("index, pid=" + pid);
                return View(m);
            }
            m.History.Add("index");
            return View(m);
        }