protected void UserInfo_ItemUpdating(object sender, DetailsViewUpdateEventArgs e) { if (Membership.GetUserNameByEmail((string)e.NewValues[0]) != null && Membership.GetUserNameByEmail((string)e.NewValues[0]).ToLower() != _user.UserName.ToLower()) { UserUpdateMessage.Text += " Email used for another user. Duplicate emails not permitted."; e.Cancel = true; } else { _user.Email = (string)e.NewValues[0]; _user.Comment = (string)e.NewValues[1]; _user.IsApproved = (bool)e.NewValues[2]; _user.LastActivityDate = lastActivitydate; CheckBox chkActive = ((DetailsView)sender).FindControl("chkActive") as CheckBox; sueetieUser.IsActive = chkActive.Checked; sueetieUser.Email = _user.Email; sueetieUser.DisplayName = txtDisplayName.Text; SueetieUsers.UpdateSueetieUser(sueetieUser); try { Membership.UpdateUser(_user); UserUpdateMessage.Text = "Update Successful."; e.Cancel = true; UserInfo.ChangeMode(DetailsViewMode.ReadOnly); if ((string)e.CommandArgument == "Email") { MailMessage msg = new MailMessage(); if (SueetieConfiguration.Get().Core.SendEmails) { AddHeaders(msg, _user); AddBody(msg, _user); SendIt(msg); } UserUpdateMessage.Text += " Approval Email has been sent!"; } } catch (Exception ex) { UserUpdateMessage.Text = "Update Failed: " + ex.Message; e.Cancel = true; UserInfo.ChangeMode(DetailsViewMode.ReadOnly); } } }
protected void btnUpdateProfile_Click(object sender, EventArgs e) { SaveProfile(); lblProfileMessage.Text = "Profile saved successfully!"; _user.LastActivityDate = lastActivitydate; Membership.UpdateUser(_user); _user = Membership.GetUser(username, false); sueetieUser = SueetieUsers.GetUser(username); sueetieUser.DisplayName = txtDisplayName.Text.Trim(); SueetieUsers.UpdateDisplayName(sueetieUser); sueetieUser.DisplayName = txtDisplayName.Text.Trim(); sueetieUser.TimeZone = Convert.ToInt32(ddTimeZones.SelectedValue); SueetieUsers.UpdateSueetieUser(sueetieUser); SueetieUsers.ClearUserProfileCache(sueetieUser.UserID); }
public void SaveProfile() { if (Page.User.Identity.IsAuthenticated) { #region Control Value Assignments if (HasNewsletterCheckBox) { Newsletter = chkNewsletter.Checked; } #endregion List <Pair> _properties = new List <Pair>() { new Pair("DisplayName", txtDisplayName.Text), new Pair("Newsletter", Newsletter.ToString()) }; Pair _propertyKeyValuePair = SueetieUsers.GenerateProfileKeyValues(_properties); SueetieUsers.UpdateSueetieUserProfile(_propertyKeyValuePair, CurrentSueetieUserID); MembershipUser user = Membership.GetUser(); user.Email = txtEmail.Text; Membership.UpdateUser(user); SueetieUser sueetieUser = new SueetieUser { UserName = CurrentSueetieUser.UserName, UserID = CurrentSueetieUser.UserID, Email = txtEmail.Text.ToLower(), DisplayName = txtDisplayName.Text, IsActive = true, TimeZone = Convert.ToInt32(ddTimeZones.SelectedValue), MembershipID = CurrentSueetieUser.MembershipID }; SueetieUsers.UpdateSueetieUser(sueetieUser); SueetieUsers.ClearUserProfileCache(CurrentSueetieUser.UserID); } }