public void update(memberCarrier carrier, string username, string password)
        {
            Authenticate(username, password);

            // Some validation
            if (carrier.Id == 0) throw new Exception("ID must be specifed when updating");
            if (carrier == null) throw new Exception("No carrier specified");

            // Get the user
            umbraco.BusinessLogic.User user = GetUser(username, password);

            // We load the member
            Member member = new Member(carrier.Id);

            // We assign the new values:
            member.LoginName = carrier.LoginName;
            member.Text = carrier.DisplayedName;
            member.Email = carrier.Email;
            member.Password = carrier.Password;

            // We iterate the properties in the carrier
            if (carrier.MemberProperties != null)
            {
                foreach (memberProperty updatedproperty in carrier.MemberProperties)
                {
                    umbraco.cms.businesslogic.property.Property property = member.getProperty(updatedproperty.Key);
                    if (property != null)
                    {
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }
        }
Exemple #2
0
        public int create(memberCarrier carrier, int memberTypeId, string username, string password)
        {
            Authenticate(username, password);

            // Some validation
            if (carrier == null)
            {
                throw new Exception("No carrier specified");
            }
            if (carrier.Id != 0)
            {
                throw new Exception("ID cannot be specifed when creating. Must be 0");
            }
            if (string.IsNullOrEmpty(carrier.DisplayedName))
            {
                carrier.DisplayedName = "unnamed";
            }

            // we fetch the membertype
            umbraco.cms.businesslogic.member.MemberType mtype = new umbraco.cms.businesslogic.member.MemberType(memberTypeId);

            // Check if the membertype exists
            if (mtype == null)
            {
                throw new Exception("Membertype " + memberTypeId + " not found");
            }

            // Get the user that creates
            umbraco.BusinessLogic.User user = GetUser(username, password);

            // Create the new member
            umbraco.cms.businesslogic.member.Member newMember = umbraco.cms.businesslogic.member.Member.MakeNew(carrier.DisplayedName, mtype, user);

            // We iterate the properties in the carrier
            if (carrier.MemberProperties != null)
            {
                foreach (memberProperty updatedproperty in carrier.MemberProperties)
                {
                    umbraco.cms.businesslogic.property.Property property = newMember.getProperty(updatedproperty.Key);
                    if (property != null)
                    {
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }
            return(newMember.Id);
        }
Exemple #3
0
        /// <summary>
        /// Creates container-object for member
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        private memberCarrier CreateMemberCarrier(umbraco.cms.businesslogic.member.Member member)
        {
            memberCarrier carrier = new memberCarrier();

            carrier.Id = member.Id;

            carrier.LoginName     = member.LoginName;
            carrier.DisplayedName = member.Text;
            carrier.Email         = member.Email;
            carrier.Password      = member.Password;

            carrier.MembertypeId   = member.ContentType.Id;
            carrier.MembertypeName = member.ContentType.Text;

            // Adding groups to member-carrier
            IDictionaryEnumerator Enumerator;

            Enumerator = member.Groups.GetEnumerator();
            while (Enumerator.MoveNext())
            {
                memberGroup group = new memberGroup(Convert.ToInt32(Enumerator.Key), ((umbraco.cms.businesslogic.member.MemberGroup)Enumerator.Value).Text);
                carrier.Groups.Add(group);
            }

            // Loading properties to carrier
            var props = member.GenericProperties;

            foreach (umbraco.cms.businesslogic.property.Property prop in props)
            {
                memberProperty carrierprop = new memberProperty();

                if (prop.Value == System.DBNull.Value)
                {
                    carrierprop.PropertyValue = null;
                }
                else
                {
                    carrierprop.PropertyValue = prop.Value;
                }

                carrierprop.Key = prop.PropertyType.Alias;
                carrier.MemberProperties.Add(carrierprop);
            }
            return(carrier);
        }
Exemple #4
0
        public void update(memberCarrier carrier, string username, string password)
        {
            Authenticate(username, password);

            // Some validation
            if (carrier.Id == 0)
            {
                throw new Exception("ID must be specifed when updating");
            }
            if (carrier == null)
            {
                throw new Exception("No carrier specified");
            }

            // Get the user
            umbraco.BusinessLogic.User user = GetUser(username, password);

            // We load the member
            Member member = new Member(carrier.Id);

            // We assign the new values:
            member.LoginName = carrier.LoginName;
            member.Text      = carrier.DisplayedName;
            member.Email     = carrier.Email;
            member.Password  = carrier.Password;

            // We iterate the properties in the carrier
            if (carrier.MemberProperties != null)
            {
                foreach (memberProperty updatedproperty in carrier.MemberProperties)
                {
                    umbraco.cms.businesslogic.property.Property property = member.getProperty(updatedproperty.Key);
                    if (property != null)
                    {
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }
        }
        /// <summary>
        /// Creates container-object for member
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        private memberCarrier CreateMemberCarrier(umbraco.cms.businesslogic.member.Member member)
        {
            memberCarrier carrier = new memberCarrier();

            carrier.Id = member.Id;

            carrier.LoginName = member.LoginName;
            carrier.DisplayedName = member.Text;
            carrier.Email = member.Email;
            carrier.Password = member.Password;

            carrier.MembertypeId = member.ContentType.Id;
            carrier.MembertypeName = member.ContentType.Text;

            // Adding groups to member-carrier
            IDictionaryEnumerator Enumerator;
            Enumerator = member.Groups.GetEnumerator();
            while (Enumerator.MoveNext())
            {
                memberGroup group = new memberGroup(Convert.ToInt32(Enumerator.Key), ((umbraco.cms.businesslogic.member.MemberGroup)Enumerator.Value).Text);
                carrier.Groups.Add(group);
            }

            // Loading properties to carrier
            var props = member.GenericProperties;
            foreach (umbraco.cms.businesslogic.property.Property prop in props)
            {
                memberProperty carrierprop = new memberProperty();

                if (prop.Value == System.DBNull.Value)
                {
                    carrierprop.PropertyValue = null;
                }
                else
                {
                    carrierprop.PropertyValue = prop.Value;
                }

                carrierprop.Key = prop.PropertyType.Alias;
                carrier.MemberProperties.Add(carrierprop);
            }
            return carrier;
        }
        public int create(memberCarrier carrier, int memberTypeId, string username, string password)
        {
            Authenticate(username, password);

            // Some validation
            if (carrier == null) throw new Exception("No carrier specified");
            if (carrier.Id != 0) throw new Exception("ID cannot be specifed when creating. Must be 0");
            if (string.IsNullOrEmpty(carrier.DisplayedName)) carrier.DisplayedName = "unnamed";

            // we fetch the membertype
            umbraco.cms.businesslogic.member.MemberType mtype = new umbraco.cms.businesslogic.member.MemberType(memberTypeId);

            // Check if the membertype exists
            if (mtype == null) throw new Exception("Membertype " + memberTypeId + " not found");

            // Get the user that creates
            umbraco.BusinessLogic.User user = GetUser(username, password);

            // Create the new member
            umbraco.cms.businesslogic.member.Member newMember = umbraco.cms.businesslogic.member.Member.MakeNew(carrier.DisplayedName, mtype, user);

            // We iterate the properties in the carrier
            if (carrier.MemberProperties != null)
            {
                foreach (memberProperty updatedproperty in carrier.MemberProperties)
                {
                    umbraco.cms.businesslogic.property.Property property = newMember.getProperty(updatedproperty.Key);
                    if (property != null)
                    {
                        property.Value = updatedproperty.PropertyValue;
                    }
                }
            }
            return newMember.Id;
        }