/// <summary> /// Takes as an input a RainbowMembershipUser, a password and a passwordAnswer and creates a user saving its profile. /// </summary> /// <param name="user">A <code>RainbowMembershipUser</code> with most of the user's data</param> /// <param name="password">the user's account password (it can't be passed in user)</param> /// <param name="passwordAnswer">the user's account password answer (it can't be passed in user)</param> /// <returns>A new <code>MembershipUser</code>. If the user was not created, CreateUser returns null.</returns> public virtual MembershipUser CreateUser(RainbowUser user, string password, string passwordAnswer) { MembershipCreateStatus status; RainbowUser membershipUser = ( RainbowUser )CreateUser(user.UserName, password, user.Email, user.PasswordQuestion, passwordAnswer, user.IsApproved, user.ProviderUserKey, out status); if (user != null) { SaveUserProfile(membershipUser); } return(membershipUser); }
/// <summary> /// Loads the user profile. /// </summary> /// <param name="user">The user.</param> protected virtual void LoadUserProfile(RainbowUser user) { ProfileBase profile = ProfileBase.Create(user.UserName); user.Name = profile.GetPropertyValue("Name").ToString(); user.Company = profile.GetPropertyValue("Company").ToString(); user.Address = profile.GetPropertyValue("Address").ToString(); user.Zip = profile.GetPropertyValue("Zip").ToString(); user.City = profile.GetPropertyValue("City").ToString(); user.CountryID = profile.GetPropertyValue("CountryID").ToString(); user.StateID = Convert.ToInt32(profile.GetPropertyValue("StateID")); user.Fax = profile.GetPropertyValue("Fax").ToString(); user.Phone = profile.GetPropertyValue("Phone").ToString(); user.SendNewsletter = Convert.ToBoolean(profile.GetPropertyValue("SendNewsletter")); }
/// <summary> /// Saves the user profile. /// </summary> /// <param name="user">The user.</param> protected virtual void SaveUserProfile(RainbowUser user) { ProfileBase profile = ProfileBase.Create(user.UserName); profile.SetPropertyValue("Name", user.Name == null ? string.Empty : user.Name); profile.SetPropertyValue("Company", user.Company == null ? string.Empty : user.Company); profile.SetPropertyValue("Address", user.Address == null ? string.Empty : user.Address); profile.SetPropertyValue("Zip", user.Zip == null ? string.Empty : user.Zip); profile.SetPropertyValue("City", user.City == null ? string.Empty : user.City); profile.SetPropertyValue("CountryID", user.CountryID == null ? string.Empty : user.CountryID); profile.SetPropertyValue("StateID", user.StateID); profile.SetPropertyValue("Fax", user.Fax == null ? string.Empty : user.Fax); profile.SetPropertyValue("Phone", user.Phone == null ? string.Empty : user.Phone); profile.SetPropertyValue("SendNewsletter", user.SendNewsletter); profile.Save(); }