protected override void PersistUpdatedItem(IMemberType entity)
        {
            ValidateAlias(entity);

            //Updates Modified date
            ((MemberType)entity).UpdatingEntity();

            //Look up parent to get and set the correct Path if ParentId has changed
            if (entity.IsPropertyDirty("ParentId"))
            {
                var parent = Database.First <NodeDto>("WHERE id = @ParentId", new { ParentId = entity.ParentId });
                entity.Path  = string.Concat(parent.Path, ",", entity.Id);
                entity.Level = parent.Level + 1;
                var maxSortOrder =
                    Database.ExecuteScalar <int>(
                        "SELECT coalesce(max(sortOrder),0) FROM umbracoNode WHERE parentid = @ParentId AND nodeObjectType = @NodeObjectType",
                        new { ParentId = entity.ParentId, NodeObjectType = NodeObjectTypeId });
                entity.SortOrder = maxSortOrder + 1;
            }

            EnsureExplicitDataTypeForBuiltInProperties(entity);
            PersistUpdatedBaseContentType(entity);

            // remove and insert - handle cmsMemberType table
            Database.Delete <MemberTypeDto>("WHERE NodeId = @Id", new { Id = entity.Id });
            var memberTypeDtos = ContentTypeFactory.BuildMemberTypeDtos(entity);

            foreach (var memberTypeDto in memberTypeDtos)
            {
                Database.Insert(memberTypeDto);
            }

            entity.ResetDirtyProperties();
        }
        protected override void PersistNewItem(IMemberType entity)
        {
            ValidateAlias(entity);

            ((MemberType)entity).AddingEntity();

            //set a default icon if one is not specified
            if (entity.Icon.IsNullOrWhiteSpace())
            {
                entity.Icon = "icon-user";
            }

            //By Convention we add 9 standard PropertyTypes to an Umbraco MemberType
            entity.AddPropertyGroup(Constants.Conventions.Member.StandardPropertiesGroupName);
            var standardPropertyTypes = Constants.Conventions.Member.GetStandardPropertyTypeStubs();

            foreach (var standardPropertyType in standardPropertyTypes)
            {
                entity.AddPropertyType(standardPropertyType.Value, Constants.Conventions.Member.StandardPropertiesGroupName);
            }

            EnsureExplicitDataTypeForBuiltInProperties(entity);
            PersistNewBaseContentType(entity);

            //Handles the MemberTypeDto (cmsMemberType table)
            var memberTypeDtos = ContentTypeFactory.BuildMemberTypeDtos(entity);

            foreach (var memberTypeDto in memberTypeDtos)
            {
                Database.Insert(memberTypeDto);
            }

            entity.ResetDirtyProperties();
        }