Esempio n. 1
0
        private void btnUpdate_ServerClick(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                // user has filled in the right values, update the user's data.
                string   nickName             = string.Empty;
                DateTime?dateOfBirth          = null;
                string   emailAddress         = string.Empty;
                bool     emailAddressIsPublic = false;
                string   iconURL                = string.Empty;
                string   ipNumber               = string.Empty;
                string   location               = string.Empty;
                string   occupation             = string.Empty;
                string   password               = string.Empty;
                string   signature              = string.Empty;
                string   website                = string.Empty;
                bool     autoSubscribeThreads   = true;
                short    defaultMessagesPerPage = 10;

                if (tbxPassword1.Value.Length > 0)
                {
                    password = tbxPassword1.Value;
                }

                emailAddress = tbxEmailAddress.Value;
                iconURL      = tbxIconURL.Value;

                if (tbxDateOfBirth.Value.Length > 0)
                {
                    try
                    {
                        dateOfBirth = System.DateTime.Parse(tbxDateOfBirth.Value, CultureInfo.InvariantCulture.DateTimeFormat);
                    }
                    catch (FormatException)
                    {
                        // format exception, date invalid, ignore, will resolve to default.
                    }
                }

                emailAddressIsPublic = !chkEmailAddressIsHidden.Checked;
                location             = tbxLocation.Value;
                occupation           = tbxOccupation.Value;
                signature            = tbxSignature.Value;
                website = tbxWebsite.Value;

                //Preferences
                autoSubscribeThreads = chkAutoSubscribeToThread.Checked;
                if (tbxDefaultNumberOfMessagesPerPage.Value.Length > 0)
                {
                    defaultMessagesPerPage = HnDGeneralUtils.TryConvertToShort(tbxDefaultNumberOfMessagesPerPage.Value);
                }

                bool result = UserManager.UpdateUserProfile(SessionAdapter.GetUserID(), dateOfBirth, emailAddress, emailAddressIsPublic, iconURL, location, occupation, password,
                                                            signature, website, SessionAdapter.GetUserTitleID(), ApplicationAdapter.GetParserData(), autoSubscribeThreads, defaultMessagesPerPage);

                if (result)
                {
                    // get user back and update session object.
                    UserEntity user = UserGuiHelper.GetUser(SessionAdapter.GetUserID());
                    if (user != null)
                    {
                        SessionAdapter.AddUserObject(user);
                    }
                    // all ok
                    Response.Redirect("EditProfileSuccessful.aspx", true);
                }
            }
        }