I am not an Orchard guru. I am a desktop apps guy with a lot of responsibilities that inherited a big blob of Orchard code and have been tasked with a few maintenance tools. I have tried googling the interwebs to no avail, so I am turning to Stack in a desperate attempt that someone has the easy button...
Basically (and this is an over-simplified use case) - we frequently have users that signup with a mistyped email address or forget their account information within a day or signup again but fat finger the password and then signup a third time, etc...
I have a maintenance console that allows an administrator to 'locate' data (in our own non-orchard sql tables) associated with the first or second accounts (in my example) and re-associate that data with the third 'current/correct' account.
At the conclusion of this re-mapping, I would like to programmatically clean-up (read: delete) the Orchard logins for the first two accounts which are now officially kruft.
I found some information on Stack here that talks about Orchard user accounts:
Users are content types and Orchard creates content items for each user. When you create a new user Orchard adds records to xxx_Orchard_Users_UserPartRecord, xxx_Orchard_Framework_ContentItemRecord, xxx_Orchard_Framework_ContentItemVersionRecord and xxx_Orchard_Roles_UserRolesPartRecord if you linked any roles to the user.
The xxx_Orchard_Framework_ContentItemVersionRecord table keeps track of the version number and whether or not a content item is published or not and which version of the published content item is the latest.
When you delete the user Orchard does not delete the records from the tables, but simply creates a new version record and sets Published and Latest columns to 0 for the new version and the old version. Because there is no published and latest version the content item does not show up on the list of users.
I understand this conceptually, but I can't believe to delete a user that I would be required to delete the records from each of these 'private' tables in orchard. Instead, I expect there is a class/method/technique for deleting the Content Type or Part or Record or whatever (I'm still haven't quite got Orchard object naming straight in my head).
Can anyone share an example of deleting a user in code (by Id or Username or Email)? Or point me at the relevant documentation? I'm fumbling around like a fish outta water here...
As always, thanks in advance!