示例#1
0
        private void SetInputsInModeMini()
        {
            if (IsPostBack)
            {
                return;
            }

            SocialHelper.RemoveSocialProfileFromSessionIfNeeded();

            var socialUserModel = SocialHelper.GetSocialProfileFormSession() != null?SocialHelper.GetSocialProfileFormSession().UserModel : SocialHelper.BindUserModel();

            if (socialUserModel != null)
            {
                if (socialUserModel.Email.HasText())
                {
                    try
                    {
                        if (SocialHelper.CanAuthenticateAsync())
                        {
                            SocialHelper.SetSocialProfileToSession(SocialHelper.CreateSocialProfileIfNeeded());
                            divEmail.Visible           = false;
                            divConfirmEmail.Visible    = false;
                            divPassword.Visible        = false;
                            divConfirmPassword.Visible = false;
                            divFirstName.Visible       = socialUserModel.FirstName.HasNoText();
                            divLastName.Visible        = socialUserModel.LastName.HasNoText();

                            if (!(inputFirstName.Visible || inputLastName.Visible))
                            {
                                divMiddleName.Visible = false;
                            }
                        }
                        else
                        {
                            divSummaryError.Visible = true;
                            ltlMessage.Text         = "Cannot validate email " + socialUserModel.Email + ". Please complete registration manually. Possible reasons: <br />1) access to email address is not allowed by user<br />2) email from social network profile is not equal to email obtained with given access token.";
                        }
                    }
                    catch (Exception ex)
                    {
                        divSummaryError.Visible = true;
                        ltlMessage.Text         = ex.Message;
                    }
                }

                inputFirstName.Value  = socialUserModel.FirstName;
                inputMiddleName.Value = socialUserModel.MiddleName;
                inputLastName.Value   = socialUserModel.LastName;

                if (socialUserModel.AvatarUrl.HasText())
                {
                    divSocImage.Visible  = true;
                    imageAvatar.ImageUrl = socialUserModel.AvatarUrl;
                }
            }
        }
示例#2
0
        private ProfileCommon SaveProfile()
        {
            var result     = Profile;
            var email      = inputEmail.Value.Trim();
            var firstName  = inputFirstName.Value.Trim();
            var middleName = inputMiddleName.Value.Trim();
            var lastName   = inputLastName.Value.Trim();
            var avatarUrl  = String.Empty;

            if (GetCurrentMode() == ModesEnum.Mini)
            {
                var socialProfile = SocialHelper.CreateSocialProfileIfNeeded();

                if (socialProfile != null)
                {
                    var userModel = socialProfile.UserModel;

                    if (email.HasNoText() && userModel.Email.HasText())
                    {
                        email = userModel.Email;
                    }
                    if (firstName.HasNoText() && userModel.FirstName.HasText())
                    {
                        firstName = userModel.FirstName;
                    }
                    if (middleName.HasNoText() && userModel.MiddleName.HasText())
                    {
                        middleName = userModel.MiddleName;
                    }
                    if (lastName.HasNoText() && userModel.LastName.HasText())
                    {
                        lastName = userModel.LastName;
                    }
                    if (userModel.AvatarUrl.HasText())
                    {
                        avatarUrl = userModel.AvatarUrl;
                    }
                }
            }

            if (email.Length > 0)
            {
                result = Profile.GetProfile(email);
            }
            else
            {
                result = Profile.GetProfile(User.Identity.Name);
            }

            result.Association = Request.Form["association"];
            result.Brokerage.BrokerageState      = ddlBrokerageState.SelectedValue.Trim();
            result.BusinessAddress.BusinessState = ddlBusinessState.SelectedValue.Trim();
            result.Preferences.Newsletter        = ddlNewsletter.SelectedValue.Trim();
            result.Title = ddlTitle.SelectedValue.Trim();
            result.Brokerage.BrokerageAddress1      = inputBrokerageAddress1.Value.Trim();
            result.Brokerage.BrokerageAddress2      = inputBrokerageAddress2.Value.Trim();
            result.Brokerage.BrokerageCity          = inputBrokerageCity.Value.Trim();
            result.Brokerage.BrokerageName          = inputBrokerageName.Value.Trim();
            result.Brokerage.BrokerageZipcode       = inputBrokerageZipCode.Value.Trim();
            result.BusinessAddress.BusinessAddress1 = inputBusinessAddress1.Value.Trim();
            result.BusinessAddress.BusinessAddress2 = inputBusinessAddress2.Value.Trim();
            result.BusinessAddress.BusinessCity     = inputBusinessCity.Value.Trim();
            result.BusinessAddress.BusinessZipcode  = inputBusinessZipCode.Value.Trim();
            result.Contact.EmailSecondary           = inputSecondaryEmail.Value.Trim();
            result.Contact.Fax              = inputBusinessFax.Value.Trim();
            result.FirstName                = firstName;
            result.LastName                 = lastName;
            result.MiddleInitial            = middleName;
            result.Contact.PhoneBusiness    = inputBusinessPhone.Value.Trim();
            result.Contact.PhoneBusinessExt = inputBusinessPhoneExt.Value.Trim();
            result.Contact.PhoneCell        = inputCellPhone.Value.Trim();
            result.Contact.PhoneHome        = inputHomePhone.Value.Trim();
            result.ReferredBy               = ddlReferredSource.SelectedValue + "|" + inputReferredBy.Value.Trim();
            result.TeamName                 = inputTeamName.Value.Trim();
            result.Website  = inputWebsite.Value.Trim();
            result.DRE      = inputBre.Value.Trim();
            result.ImageURL = avatarUrl;

            result.Save();

            if (result.ImageURL.HasText())
            {
                SaveAvatar(result.ImageURL, result);
            }

            return(result);
        }
示例#3
0
        private void Save()
        {
            try
            {
                ValidateOnSave();

                var email    = inputEmail.Value.Trim();
                var password = inputPassword.Value;

                if (GetCurrentMode() == ModesEnum.Mini)
                {
                    var socialProfile = SocialHelper.CreateSocialProfileIfNeeded();

                    if (email.HasNoText())
                    {
                        email = socialProfile.UserModel.Email;
                    }

                    if (password.HasNoText())
                    {
                        password = GeneratePassword();
                    }
                }

                var user    = Membership.CreateUser(email, password, email);
                var profile = SaveProfile();

                InsertSubscriber(profile);

                if (Membership.ValidateUser(user.UserName, user.GetPassword()))
                {
                    try
                    {
                        SendEmail(user, profile);
                    }
                    catch
                    {
                    }

                    if (Request.QueryString["ReturnUrl"] != null)
                    {
                        FormsAuthentication.RedirectFromLoginPage(user.Email, false);
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(user.Email, false);
                        Response.Redirect("~/createflyer.aspx");
                    }
                }
            }
            catch (MembershipCreateUserException ex)
            {
                divSummaryError.Visible = true;

                switch (ex.StatusCode)
                {
                case MembershipCreateStatus.DuplicateEmail:
                    ltlMessage.Text = "You have supplied a duplicate email address.";
                    break;

                case MembershipCreateStatus.DuplicateUserName:
                    ltlMessage.Text = "You have supplied a duplicate username.";
                    break;

                case MembershipCreateStatus.InvalidEmail:
                    ltlMessage.Text = "You have not supplied a proper email address.";
                    break;

                default:
                    ltlMessage.Text = "Error: " + ex.Message;
                    break;
                }
            }
            catch (Exception ex)
            {
                divSummaryError.Visible = true;
                ltlMessage.Text         = String.Format("Unhandled error: {0}", ex.Message);
            }
        }
示例#4
0
        private void ValidateOnSave()
        {
            if (GetCurrentMode() == ModesEnum.Main || (GetCurrentMode() == ModesEnum.Mini && SocialHelper.CreateSocialProfileIfNeeded() == null))
            {
                if (inputEmail.Value.HasNoText())
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Email is required.");
                }
                else if (String.Compare(inputEmail.Value, inputEmailConfirm.Value, true) != 0)
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Emails do not match.");
                }
                else if (String.Compare(inputEmail.Value, inputEmailConfirm.Value, true) != 0)
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Emails do not match.");
                }
                else if (inputPassword.Value.HasNoText())
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Password is required.");
                }
                else if (inputConfirmPassword.Value.HasNoText())
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Confirm Password is required.");
                }
                else if (String.Compare(inputPassword.Value, inputConfirmPassword.Value, false) != 0)
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Passwords do not match.");
                }
                else if (inputFirstName.Value.HasNoText())
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "First Name is required.");
                }
                else if (inputLastName.Value.HasNoText())
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Last Name is required.");
                }
            }
            else if (GetCurrentMode() == ModesEnum.Mini && SocialHelper.CreateSocialProfileIfNeeded() != null)
            {
                var socialProfile = SocialHelper.CreateSocialProfileIfNeeded();
                var userModel     = socialProfile.UserModel;

                if (userModel.FirstName.HasNoText() && inputFirstName.Value.HasNoText())
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "First Name is required.");
                }
                else if (userModel.LastName.HasNoText() && inputLastName.Value.HasNoText())
                {
                    Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Last Name is required.");
                }
            }

            if (ddlTitle.SelectedValue.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Select Title.");
            }
            else if (ddlTitle.Items.FindByValue(ddlTitle.SelectedValue) == null)
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Provide valid Title.");
            }
            else if (inputBusinessAddress1.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Business Address 1 is required.");
            }
            else if (inputBusinessCity.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Business City is required.");
            }
            else if (ddlBusinessState.SelectedValue.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Select your Business State.");
            }
            else if (ddlBusinessState.Items.FindByValue(ddlBusinessState.SelectedValue) == null)
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Provide valid Business State.");
            }
            else if (inputBusinessZipCode.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Business Zip Code is required.");
            }
            else if (inputBusinessPhone.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Business Phone is required.");
            }
            else if (inputBrokerageName.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Brokerage Name is required.");
            }
            else if (inputBrokerageAddress1.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Brokerage Address 1 is required.");
            }
            else if (inputBrokerageCity.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Brokerage City is required.");
            }
            else if (ddlBusinessState.SelectedValue.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Select Brokerage State.");
            }
            else if (ddlBusinessState.Items.FindByValue(ddlBusinessState.SelectedValue) == null)
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Provide valid Brokerage State.");
            }
            else if (inputBrokerageZipCode.Value.HasNoText())
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Zip Code is required.");
            }
            else if (!cbTerm.Checked)
            {
                Helper.SetErrorResponse(HttpStatusCode.BadRequest, "Accept Terms and Conditions.");
            }
        }