Edit view not rendering

Topics: Customizing Orchard, Troubleshooting
Aug 17, 2015 at 4:09 PM
Here's an odd one, that I've been staring at all day so far. I'm creating a new content part, and while I can get the view that will display the added part, the view to let me add/edit it won't show.

Code simplified for ease here

Models - PMUserPart
  public class PMUserPart : ContentPart<PMUserRecord>
    {
        public int UserID
        {
            get { return Record.UserID; }
            set { UserID = value; }
        }

        public string Gender
        {
            get { return Record.Gender; }
            set { Gender = value; }
        }

        public string Company
        {
            get { return Record.Company; }
            set { Company = value; }
        }
}
PMUserPartRecord
public class PMUserRecord : ContentPartRecord
    {
        public virtual int UserID { get; set; }
        public virtual string Gender { get; set; }
        public virtual string Company { get; set; }
}
handler
    public class PMUserHandler : ContentHandler
    {
        public PMUserHandler(IRepository<PMUserRecord> repository)
        {
            Filters.Add(StorageFilter.For(repository));
        }
    }
Driver
    {
        protected override string Prefix
        {
            get
            {
                return "tbl";
            }
        }

        protected override DriverResult Display(PMUserPart part, string displayType, dynamic shapeHelper)
        { 
            var x=ContentShape("Parts_PMUser", () => shapeHelper.Parts_PMUser(ContentPart:part));
            return x;
        }

        protected override DriverResult Editor(PMUserPart part, dynamic shapeHelper)
        {
            var x= ContentShape("Parts_PMUser_Edit",
                     () => shapeHelper.EditorTemplate(TemplateName: "Parts/PMUser", Model: part, Prefix: Prefix));
            return x;
        }

        protected override DriverResult Editor(PMUserPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix , null, null);
            return Editor(part, shapeHelper);
        }
Migrations
    public class Migrations : DataMigrationImpl {

        public int Create() {
            // Creating table tbl_PMUser_PMUserRecord
            SchemaBuilder.CreateTable("PMUserRecord", 
                table => table
                    .ContentPartRecord()
                    .Column("UserID", DbType.Int32)
                    .Column("Gender", DbType.String)
                    .Column("Company", DbType.String)
                  
            );

            ContentDefinitionManager.AlterPartDefinition(
                typeof(PMUserPart).Name, cfg => cfg.Attachable());

            return 1;
        }
My razor views are both called PMUser, one is in Views/EditorTemplates/Parts, the other in Views/Parts. The one called from the display function in the driver appears, the other does not, I created a new content type, attached the common part and my part to it, and when I try to create a new PMUser from that content type, I just see the common part and the save & publish now buttons. Pressing save does create a new blank PMUser, and listing all content shows me that it has been created, along with a view that has no data in it.

I've been staring at it all afternoon! Help? Please?
Aug 18, 2015 at 3:01 PM
Solved with the aid of this module.

I backed up my code, un-installed it. Then used the code generations extensions to recreate the module, then add a part to it. Not sure what the differences were in the code, and I suspect it may well have been that oh so elusive typo that catches even the best of us out at times.

Anyway, I now have working code :)

Thank you Piotr Szmyd