Пример #1
0
        /// <summary>
        /// Takes as an input a AppleseedMembershipUser, a password and a passwordAnswer and creates a user saving its profile.
        /// </summary>
        /// <param name="user">
        /// A
        /// <code>
        /// AppleseedMembershipUser
        /// </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(AppleseedUser user, string password, string passwordAnswer)
        {
            MembershipCreateStatus status;

            var membershipUser =
                (AppleseedUser)
                this.CreateUser(
                    user.UserName,
                    password,
                    user.Email,
                    user.PasswordQuestion,
                    passwordAnswer,
                    user.IsApproved,
                    user.ProviderUserKey,
                    out status);

            this.SaveUserProfile(membershipUser);

            return(membershipUser);
        }
Пример #2
0
        /// <summary>
        /// Loads the user profile.
        /// </summary>
        /// <param name="user">
        /// The Appleseed user.
        /// </param>
        protected virtual void LoadUserProfile(AppleseedUser user)
        {
            var profile = ProfileBase.Create(user.UserName);

            try
            {
                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"));
            }
            catch (SettingsPropertyNotFoundException)
            {
                // TODO: loggear el error, no se que logger usar. Si referencio a alguno de los que se usa en el resto de la solucion da una referencia circular.
            }
        }
Пример #3
0
        /// <summary>
        /// Saves the user profile.
        /// </summary>
        /// <param name="user">
        /// The Appleseed user.
        /// </param>
        protected virtual void SaveUserProfile(AppleseedUser user)
        {
            var profile = ProfileBase.Create(user.UserName);

            try
            {
                profile.SetPropertyValue("Name", user.Name ?? string.Empty);
                profile.SetPropertyValue("Company", user.Company ?? string.Empty);
                profile.SetPropertyValue("Address", user.Address ?? string.Empty);
                profile.SetPropertyValue("Zip", user.Zip ?? string.Empty);
                profile.SetPropertyValue("City", user.City ?? string.Empty);
                profile.SetPropertyValue("CountryID", user.CountryID ?? string.Empty);
                profile.SetPropertyValue("StateID", user.StateID);
                profile.SetPropertyValue("Fax", user.Fax ?? string.Empty);
                profile.SetPropertyValue("Phone", user.Phone ?? string.Empty);
                profile.SetPropertyValue("SendNewsletter", user.SendNewsletter);
                profile.Save();
            }
            catch (SettingsPropertyNotFoundException)
            {
                // TODO: loggear el error, no se que logger usar. Si referencio a alguno de los que se usa en el resto de la solucion da una referencia circular.
            }
        }
 /// <summary>
 /// Saves the user profile.
 /// </summary>
 /// <param name="user">
 /// The Appleseed user.
 /// </param>
 protected virtual void SaveUserProfile(AppleseedUser user)
 {
     var profile = ProfileBase.Create(user.UserName);
     try
     {
         profile.SetPropertyValue("Name", user.Name ?? string.Empty);
         profile.SetPropertyValue("Company", user.Company ?? string.Empty);
         profile.SetPropertyValue("Address", user.Address ?? string.Empty);
         profile.SetPropertyValue("Zip", user.Zip ?? string.Empty);
         profile.SetPropertyValue("City", user.City ?? string.Empty);
         profile.SetPropertyValue("CountryID", user.CountryID ?? string.Empty);
         profile.SetPropertyValue("StateID", user.StateID);
         profile.SetPropertyValue("Fax", user.Fax ?? string.Empty);
         profile.SetPropertyValue("Phone", user.Phone ?? string.Empty);
         profile.SetPropertyValue("SendNewsletter", user.SendNewsletter);
         profile.Save();
     }
     catch (SettingsPropertyNotFoundException)
     {
         // TODO: loggear el error, no se que logger usar. Si referencio a alguno de los que se usa en el resto de la solucion da una referencia circular.
     }
 }
        /// <summary>
        /// Loads the user profile.
        /// </summary>
        /// <param name="user">
        /// The Appleseed user.
        /// </param>
        protected virtual void LoadUserProfile(AppleseedUser user)
        {
            var profile = ProfileBase.Create(user.UserName);

            try
            {
                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"));
            }
            catch (SettingsPropertyNotFoundException)
            {
                // TODO: loggear el error, no se que logger usar. Si referencio a alguno de los que se usa en el resto de la solucion da una referencia circular.
            }
        }
        /// <summary>
        /// Takes as an input a AppleseedMembershipUser, a password and a passwordAnswer and creates a user saving its profile.
        /// </summary>
        /// <param name="user">
        /// A 
        /// <code>
        /// AppleseedMembershipUser
        /// </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(AppleseedUser user, string password, string passwordAnswer)
        {
            MembershipCreateStatus status;

            var membershipUser =
                (AppleseedUser)
                this.CreateUser(
                    user.UserName,
                    password,
                    user.Email,
                    user.PasswordQuestion,
                    passwordAnswer,
                    user.IsApproved,
                    user.ProviderUserKey,
                    out status);

            this.SaveUserProfile(membershipUser);

            return membershipUser;
        }
        public void UpdateUserTest2()
        {
            try
            {
                AppleseedUser user = new AppleseedUser(Membership.Provider.Name, "invalidUserName", Guid.NewGuid(), "*****@*****.**", "question", "answer", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.MinValue);

                Membership.UpdateUser(user);

                Assert.Fail("UpdateUser didn't throw an exception even though userName was invalid");
            }
            catch (AppleseedMembershipProviderException)
            {
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + ex.StackTrace);
                Assert.Fail("Error in UpdateUserTest1", ex);
            }
        }