Esempio n. 1
0
        /// <summary>
        /// Handles the Click event of the SaveButton control.
        /// </summary>
        /// <param name="s">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void SaveButton_Click(object s, EventArgs e)
        {
            var membershipUser = UserManager.GetUser(User.Identity.Name);

            membershipUser.Email           = Email.Text;
            WebProfile.Current.FirstName   = FirstName.Text;
            WebProfile.Current.LastName    = LastName.Text;
            WebProfile.Current.DisplayName = FullName.Text;

            try
            {
                WebProfile.Current.Save();
                Membership.UpdateUser(membershipUser);

                Message1.ShowSuccessMessage(GetLocalResourceObject("ProfileSaved").ToString());

                if (Log.IsInfoEnabled)
                {
                    if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        MDC.Set("user", HttpContext.Current.User.Identity.Name);
                    }
                    Log.Info("Profile updated");
                }
            }
            catch (Exception ex)
            {
                if (Log.IsErrorEnabled)
                {
                    if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
                    {
                        MDC.Set("user", HttpContext.Current.User.Identity.Name);
                    }
                    Log.Error("Profile update error", ex);
                }

                Message1.ShowErrorMessage(GetLocalResourceObject("ProfileUpdateError").ToString());
            }
        }