Ejemplo n.º 1
0
        protected void uxSubmit_Click(object sender, EventArgs e)
        {
            // server-side validation
            string name     = string.Empty;
            string email    = string.Empty;
            string password = string.Empty;

            string zip            = uxZipCode.Text.RemoveHTML();
            bool   newsletter     = uxNewsletterSignup.Checked;
            bool   isFacebookUser = !string.IsNullOrEmpty(AccessToken);

            if (!string.IsNullOrEmpty(uxFirstName.Text))
            {
                name = uxFirstName.Text.RemoveHTML();
            }

            if (!string.IsNullOrEmpty(uxEmailAddress.Text))
            {
                email = uxEmailAddress.Text;
            }

            if (isFacebookUser)
            {
                password = Constants.FacebookMember_Password;
            }
            else if (!string.IsNullOrEmpty(uxPassword.Text) && !string.IsNullOrEmpty(uxPasswordConfirm.Text) && uxPassword.Text == uxPasswordConfirm.Text)
            {
                password = uxPassword.Text;
            }

            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(email) && !string.IsNullOrEmpty(password))
            {
                // damnit barry, this is how you get ants.
                // the site keeps breaking when we test, and its breaking ugly.
                // if someone clicks to create a new user, we have to blow up the existing user or we're going to have a problem.
                this.FlushRegisteringUser();

                //everything's cool
                if (this.registeringUser == null)
                {
                    this.registeringUser = new Domain.Membership.Member();
                }

                this.registeringUser.FirstName = name;

                //bg: adding in zip code
                this.registeringUser.ZipCode = zip.Trim();

                //adding marker for FB users
                this.registeringUser.isFacebookUser = isFacebookUser;

                var membershipManager = new MembershipManager();

                try
                {
                    // helps to call the right addMember method...
                    this.registeringUser = membershipManager.AddMember(this.registeringUser, email, password);
                }
                catch (Exception ex)
                {
                    uxErrorMessage.Text = ex.Message;
                    return;
                }

                this.CurrentMember = this.registeringUser;
                this.CurrentUser   = membershipManager.GetUser(this.CurrentMember.MemberId);

                Response.Redirect(TermsandConditionsItem.GetTermsAndConditionsPage().GetUrl());
            }
            else
            {
                //something failed...
                uxErrorMessage.Text = DictionaryConstants.SomethingFailedError;
            }
        }