I can't seem to store additional data in a separate contentpart attached to User. I have done the following:
- Created a module
- In the module I created a Model for ProfilePart and ProfilePartRecord
- In the migration I created a table for ProfilePartRecord (from type ContentPartRecord)
- In the migration I altered the typedefinition for User, by setting WithPart ProfilePart
- I created a driver class, that has 2 edit methods, one for get and one for post (code snippets are below
- I also created a handler that adds a storage filter for profilePartRepository of type ProfilePartRecord
Module Structure
- Drivers/ProfilePartDriver.cs
- Handlers/ProfileHandler.cs
- Models/ProfilePart.cs
- Models/ProfilePartRecord.cs
- Views/EditorTemplates/Parts/profile.cshtml
- Migrations.cs
- Placement.info
Since I think the issue is in the Driver. This is my code:
Is it going wrong because the part is attached to User? Or am I missing something else.
public class ProfilePartDriver:ContentPartDriver {
protected override string Prefix
{
get { return "Profile"; }
}
//GET
protected override DriverResult Editor(ProfilePart part, dynamic shapeHelper)
{
return ContentShape("Parts_Profile_Edit", () =>
shapeHelper.EditorTemplate(TemplateName: "Parts/Profile", Model: part, Prefix: Prefix));
}
//POST
protected override DriverResult Editor(ProfilePart part, IUpdateModel updater, dynamic shapeHelper)
{
updater.TryUpdateModel(part, Prefix, null, null);
return Editor(part, shapeHelper);
}
}