ContentItem containing existing user

Topics: Customizing Orchard
Oct 24, 2013 at 2:46 AM
I've been trying to make a Content type for a module which extends the standard orchard user with a few extra fields. After following the skywalker webshop module tutorial, I've managed to create a content item containing my custom content part, and a UserPart, however every time I try to add an existing user's UserPartRecord to the content item, it just ends up doubling up the user in the database.

Is there a way of attaching an "existing" UserPartRecord to a content item? Or will I just have to live with the double ups? Here is my code so far (copied liberally from the skywalker webshop module):
        public TranslatorPart CreateTranslator()
            var user = _authenticationService.GetAuthenticatedUser();
            if (user != null)
                TranslatorPart translatorPart = this.GetTranslator(user);
                if (translatorPart == null)
                    var translator = _services.ContentManager.New("Translator");
                    UserPart userPart = translator.As<UserPart>();
                    UserPart currentUser = user.ContentItem.As<UserPart>();
                    translatorPart = translator.As<TranslatorPart>();

                    userPart.UserName = currentUser.UserName;
                    userPart.Email = currentUser.Email;
                    userPart.NormalizedUserName = currentUser.NormalizedUserName;
                    userPart.Record.HashAlgorithm = currentUser.Record.HashAlgorithm;
                    userPart.Record.RegistrationStatus = currentUser.Record.RegistrationStatus;
                    userPart.Record.EmailStatus = currentUser.Record.EmailStatus;

                    translatorPart.CreatedUtc = _clock.UtcNow;


                return translatorPart;

            return null;
Any ideas on how I can make this neater so I don't have to create a second UserPart which is a copy of the original?

Oct 26, 2013 at 7:54 AM
I don't understand why you are creating a new content item. In any case, a content part is attached to one and only one content item. I don't understand what you are trying to do, but whatever it is, this is not the way of implementing it. Why not augment the existing user content item for example?