Ejemplo n.º 1
0
    protected void Page_PreInit(object sender, EventArgs e)
    {
        DuplicateUserName = false;
        DuplicateEmail = false;
        RegisteredForCurrentYear = false;
        CaptchaInvalid = false;
        DoValidation = false;

        PageMode = RegistrationPageMode.NotRegistered;
        if (Context.User.Identity.IsAuthenticated)
        {
            RegisteredForCurrentYear =
                Utils.IsRegisteredForCurrentCodeCampYear(Context.User.Identity.Name, Utils.CurrentCodeCampYear);
            if (RegisteredForCurrentYear)
            {
                PageMode = RegistrationPageMode.UpdateRegisteredThisYear;
            }
            else
            {
                PageMode = RegistrationPageMode.UpdateNotRegisteredThisYear;
            }

        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int maxRegistration = Convert.ToInt32(ConfigurationManager.AppSettings["MaxRegistration"] ?? "99999999");
        int numberRegisteredCurrentYear = Utils.GetNumberRegistered();
        bool registrationClosed = numberRegisteredCurrentYear > maxRegistration;

        // if not logged in, don't let them go to registratoin page if full
        if (!Context.User.Identity.IsAuthenticated && registrationClosed)
        {
            Response.Redirect("~/CodeCampClosedForRegistration.aspx");
        }

        if (!IsPostBack)
        {
            int sponsorListId = Utils.GetSponsorIdBasedOnUsername(Context.User.Identity.Name);
            if (sponsorListId > 0)
            {
                var rec = SponsorListManager.I.Get(new SponsorListQuery() { Id = sponsorListId }).FirstOrDefault();
                HyperLinkSponsorInformation.Text = String.Format(
                    "Sponsorship Information For {0}", rec.SponsorName);
                HyperLinkSponsorInformation.Visible = true;
            }
        }

        // if logged in, but currently not registered for saturday or sunday, don't let them login in unless special role set

        if (Context.User.Identity.IsAuthenticated && registrationClosed)
        {
            if (!Utils.CheckUserIsAllowRegistration()
                && !Utils.CheckUserIsVolunteerCoordinator() && !Utils.CheckUserIsPresenterOrAdmin())
            {
                int attendeeId = Utils.GetAttendeesIdFromUsername(Context.User.Identity.Name);
                var attendeeRec = AttendeesManager.I.Get(new AttendeesQuery() {Id = attendeeId}).FirstOrDefault();
                if (attendeeRec != null)
                {

                    if (!Utils.IsRegisteredForCurrentCodeCampYear(Context.User.Identity.Name,
                                                                 Utils.CurrentCodeCampYear))
                    {
                        Response.Redirect("~/CodeCampClosedForRegistration.aspx");
                    }
                }

            }

        }

        // could optimize below if statement)
        if ((ConfigurationManager.AppSettings["SubmitSessionsOpen"] != null &&
            ConfigurationManager.AppSettings["SubmitSessionsOpen"].Equals("true")) || Utils.CheckUserIsSubmitSession() ||
            Utils.CheckUserIsAdmin())
        {
            CheckBoxSpeakerDDL.Enabled = true;
            LabelSessionClosedMessage.Text = String.Empty;
        }
        else
        {
            CheckBoxSpeakerDDL.Enabled = false;
            LabelSessionClosedMessage.Text = "Sessions are closed to new submissions";
        }

        if (Request.QueryString["PKID"] != null)
        {
            string guidString = Request.QueryString["PKID"];
            string username = Utils.GetAttendeeUsernameByGUID(guidString);
            if (!String.IsNullOrEmpty(username))
            {
                if (!Utils.GetIgnoreAutoSignOnGuid(username))
                {
                    if (!string.IsNullOrEmpty(username))
                    {
                        if (User.Identity.IsAuthenticated)
                        {
                            FormsAuthentication.SignOut();
                        }
                        FormsAuthentication.SetAuthCookie(username, true);
                        Response.Redirect("~/Register.aspx", true);
                    }
                }
            }
        }

        if (PageMode == RegistrationPageMode.NotRegistered)
        {
            if (!IsPostBack)
            {
                RegisteringEasyFreeId.Text = "Registering is easy and FREE!";
                LoggedInButNotRegisteredThisYearID.Visible = false;
                ButtonUpdateOrRegister.Text = "Register";
                ButtonRegisterOrUpdate1.Text = "Register";
                //ButtonCancelRegistration.Visible = false;
                //ButtonUnsubscribe.Visible = false;
            }
        }

        if (Context.User.Identity.IsAuthenticated)
        {
            int attendeeId = Utils.GetAttendeesIdFromUsername(Context.User.Identity.Name);
            bool isSpeakingThisYear = Utils.CheckAttendeeIdIsSpeaker(attendeeId);

            if (isSpeakingThisYear)
            {
                if (ConfigurationManager.AppSettings["SpeakerShirtSizes"] != null)
                {
                    string list = ConfigurationManager.AppSettings["SpeakerShirtSizes"];
                    char[] splitchar = { ',' };
                    List<string> newList = list.Split(splitchar).ToList();
                    DropDownListSpeakerShirtSize.Items.Add("--Not Selected");
                    foreach (var item in newList)
                    {
                        DropDownListSpeakerShirtSize.Items.Add(new ListItem(item.Trim(), item.Trim()));
                    }
                }
                SpeakerShirtSizeDiv.Visible = true;
            }

            IDRegistrationInfo.Visible = true;
            IDAuthenticated.Visible = true;

            Attendee =
                AttendeesManager.I.Get(new AttendeesQuery
                                           {
                                               Id = attendeeId
                                           }).FirstOrDefault();

            if (Attendee != null && !IsPostBack)
            {
                ButtonUpdateOrRegister.Text = GetButtonRegisterOrUpdateText();
                ButtonRegisterOrUpdate1.Text = GetButtonRegisterOrUpdateText();
                TextBoxPhoneNumber.Text = Attendee.PhoneNumber;
                TextBoxFalafelEventBoardEmail.Text = Attendee.EmailEventBoard;

                ListItem listItem = DropDownListSpeakerShirtSize.Items.FindByValue(Attendee.ShirtSize);
                if (listItem != null)
                {
                    DropDownListSpeakerShirtSize.SelectedValue = listItem.Value;
                }

                CheckBoxAllowEmailFromSpeakerInterested.Checked = Attendee.AllowEmailToSpeakerInterested != null ? Attendee.AllowEmailToSpeakerInterested.Value : false;
                CheckBoxAllowEmailFromSpeakerPlanToAttend.Checked = Attendee.AllowEmailToSpeakerPlanToAttend != null ? Attendee.AllowEmailToSpeakerPlanToAttend.Value : false;
                CheckBoxQRPhoneNumber.Checked = Attendee.QRPhoneAllow != null ? Attendee.QRPhoneAllow.Value : false;

                if (Attendee.EmailSubscription != null)
                {
                    RadioButtonListEmailSubcription.SelectedIndex = Attendee.EmailSubscription.Value;
                }
                else
                {
                    Attendee.EmailSubscription = (int) EmailSubscriptionEnum.AllEmails;
                    RadioButtonListEmailSubcription.SelectedIndex = 0;
                }
                LabelEmailStatusMessage.Text = Attendee.EmailSubscriptionStatus;

                if (Attendee.EmailSubscription == 2)
                {
                    LabelEmailBouncing.Visible = true;
                }

            }

            // Need to see if person already registered for this year.  If so, then take them to profile page
            var attendeesCodeCampYearResult =
                AttendeesCodeCampYearManager.I.Get(new AttendeesCodeCampYearQuery()
                                                       {
                                                           AttendeesId = attendeeId,
                                                           CodeCampYearId = Utils.CurrentCodeCampYear
                                                       }).FirstOrDefault();

            // keep value from being overwritten when autopostback true happens.
            if (attendeesCodeCampYearResult != null && !IsPostBack)
            {
                CheckBoxSaturday.Checked = attendeesCodeCampYearResult.AttendSaturday;
                CheckBoxSunday.Checked = attendeesCodeCampYearResult.AttendSunday;
                CheckBoxVolunteer.Checked = attendeesCodeCampYearResult.Volunteer ?? false;
            }
            else if (CheckBoxUnableToAttend.Checked)
            {
                CheckBoxSaturday.Checked = false;
                CheckBoxSunday.Checked = false;
                var rec = AttendeesCodeCampYearManager.I.Get(new AttendeesCodeCampYearQuery()
                {
                    AttendeesId =
                        attendeeId,
                    CodeCampYearId =
                        Utils.CurrentCodeCampYear,
                }).FirstOrDefault();
                if (rec != null)
                {
                    AttendeesCodeCampYearManager.I.Delete(rec.Id);
                }
                PageMode = RegistrationPageMode.UpdateNotRegisteredThisYear;
            }

            if (PageMode == RegistrationPageMode.UpdateNotRegisteredThisYear)
            {
                RegisteringEasyFreeId.Text = "Update Your Profile For This Year Now!";
                LoggedInButNotRegisteredThisYearID.Visible = true;
                //ButtonCancelRegistration.Visible = false;
                //ButtonUnsubscribe.Visible = true;
            }
            else if (PageMode == RegistrationPageMode.UpdateRegisteredThisYear)
            {
                RegisteringEasyFreeId.Text = "Update Your Profile!";
                LoggedInButNotRegisteredThisYearID.Visible = false;
                //ButtonCancelRegistration.Visible = true;
                //ButtonUnsubscribe.Visible = true;
            }

            //// check if person has sessions.  If so, then make CheckBoxSpeakerDDL default ot Yes
            //List<int> allSessionIdsByAttendeeId =
            //    SessionPresenterManager.I.Get(new SessionPresenterQuery()
            //                                      {
            //                                          AttendeeId = attendeeId
            //                                      }).Select(a => a.SessionId).ToList();
            //int sessionsThisYearCnt = SessionsManager.I.Get(
            //    new SessionsQuery
            //        {
            //            Ids = allSessionIdsByAttendeeId
            //        }).Count;

            if (isSpeakingThisYear)
            {
                CheckBoxSpeakerDDL.SelectedIndex = 0; // first choice is YES
            }

            if (!IsPostBack)
            {
                CaptchaUltimateControl1.DataBind();
            }
        }
        else
        {
            IDRegistrationInfo.Visible = true;
            IDAuthenticated.Visible = false;
            //CaptchaUltimateControl1.Visible = true;
            //LoginStatus1.Visible = false;
            //ShowMessage.Visible = true;
        }

        // check and see if a referral URL is coming in.  If so, keep it for adding
        // to user account
        try
        {
            if (Request.QueryString["Referral"] != null)
            {
                string referralPKIDString = Request.QueryString["Referral"];
                var referralGuid = new Guid(referralPKIDString);
                Items["ReferralGuid"] = referralGuid;
            }
            else if (Session["ReferralGuid"] != null)
            {
                Items["ReferralGuid"] = (Guid) Session["ReferralGuid"];
            }
        }
        catch (Exception ee)
        {
            throw new ApplicationException(ee.ToString());
        }

        //FileUpload fileUpload = (FileUpload) CaptchaUltimateControl1.FindControl("FileUpload1");
        //string str = fileUpload.FileName;
        //string str1 = fileUpload.

        //if (Context.User.Identity.IsAuthenticated)
        //{
        //    int attendeeId = Utils.GetAttendeesIdFromUsername(Context.User.Identity.Name);
        //    AttendeesResult attendeeResultRec =
        //        AttendeesManager.I.Get(new AttendeesQuery() {Id = attendeeId}).FirstOrDefault();
        //    if (attendeeResultRec != null)
        //    {
        //        int totalRecs = (EmailOptOutManager.I.Get(
        //            new EmailOptOutQuery()
        //                {
        //                    Email = attendeeResultRec.Email
        //                })).Count;
        //        if (totalRecs > 0)
        //        {
        //            ButtonReSubscribe.Visible = true;
        //            ButtonUnsubscribe.Visible = false;
        //        }
        //        else
        //        {
        //            ButtonReSubscribe.Visible = false;
        //            ButtonUnsubscribe.Visible = true;
        //        }
        //    }
        //}
    }