content management system - Orchard CMS Driver's Editor Override Not Firing -


using orchard 1.7.

the goal: create collection of we're calling page filters.

to create many many part followed tutorial steps described here

the problem: editor override in driver class never hit , empty create page nothing save button being returned.

model classes:

namespace mylib.orchard.hyperlinkitemmanager.models {     public class hyperlinkpagefilterrecord     {         public virtual int id { get; set; }         public virtual int pageid { get; set; }     } }  namespace mylib.orchard.hyperlinkitemmanager.models {     public class hyperlinkpagefilterscontentrecord     {         public virtual int id { get; set; }         public virtual hyperlinkpagefilterspartrecord hyperlinkpagefilterspartrecord { get; set; }         public virtual hyperlinkpagefilterrecord hyperlinkpagefilterrecord { get; set; }     }  } namespace mylib.orchard.hyperlinkitemmanager.models {     public class hyperlinkpagefilterspart : contentpart<hyperlinkpagefilterspartrecord>     {         public ienumerable<hyperlinkpagefilterrecord> hyperlinkpagefilters         {                         {                 return record.hyperlinkpagefilters.select(r => r.hyperlinkpagefilterrecord);             }         }     } }   namespace mylib.orchard.hyperlinkitemmanager.models {     public class hyperlinkpagefilterspartrecord : contentpartrecord     {         public virtual ilist<hyperlinkpagefilterscontentrecord> hyperlinkpagefilters { get; set; }         public hyperlinkpagefilterspartrecord()         {             hyperlinkpagefilters = new list<hyperlinkpagefilterscontentrecord>();         }     } } 

view model class:

namespace mylib.orchard.hyperlinkitemmanager.models {     public class hyperlinkpagefilterseditviewmodel     {         public ilist<hyperlinkpagefilterentry> hyperlinkpagefilters { get; set; }     }      public class hyperlinkpagefilterentry     {         public hyperlinkpagefilterrecord hyperlinkpagefilter { get; set; }         public bool ischecked { get; set; }     } } 

services:

   namespace mylib.orchard.hyperlinkitemmanager.services     {         public interface ihyperlinkpagefiltersservice : idependency         {             void updatehyperlinkpagefiltersforcontentitem(                 contentitem item,                 ienumerable<hyperlinkpagefilterentry> hyperlinkpagefilters);             ienumerable<hyperlinkpagefilterrecord> gethyperlinkpagefilters();         }          public class hyperlinkpagefiltersservice : ihyperlinkpagefiltersservice         {             private readonly irepository<hyperlinkpagefilterrecord>                 _hyperlinkpagefilterrepository;             private readonly irepository<hyperlinkpagefilterscontentrecord>                 _contenthyperlinkpagefiltersrepository;              public hyperlinkpagefiltersservice(                 irepository<hyperlinkpagefilterrecord> hyperlinkpagefilterrepository,                 irepository<hyperlinkpagefilterscontentrecord> contenthyperlinkpagefiltersrepository)             {                  _hyperlinkpagefilterrepository = hyperlinkpagefilterrepository;                 _contenthyperlinkpagefiltersrepository = contenthyperlinkpagefiltersrepository;             }              public void updatehyperlinkpagefiltersforcontentitem(                 contentitem item,                 ienumerable<hyperlinkpagefilterentry> hyperlinkpagefilters)             {                  var record = item.as<hyperlinkpagefilterspart>().record;                 var oldhyperlinkpagefilters = _contenthyperlinkpagefiltersrepository.fetch(                     r => r.hyperlinkpagefilterspartrecord == record);                 var lookupnew = hyperlinkpagefilters                     .where(e => e.ischecked)                     .select(e => e.hyperlinkpagefilter)                     .todictionary(r => r, r => false);                 // delete rewards no longer there                 // , mark ones should stay                 foreach (var contenthyperlinkpagefiltersrecord in oldhyperlinkpagefilters)                 {                     if (lookupnew.containskey(                         contenthyperlinkpagefiltersrecord.hyperlinkpagefilterrecord))                     {                          lookupnew[contenthyperlinkpagefiltersrecord.hyperlinkpagefilterrecord]                             = true;                     }                     else                     {                         _contenthyperlinkpagefiltersrepository.delete(contenthyperlinkpagefiltersrecord);                     }                 }                 // add new rewards                 foreach (var hyperlinkpagefilter in lookupnew.where(kvp => !kvp.value)                                                .select(kvp => kvp.key))                 {                     _contenthyperlinkpagefiltersrepository.create(new hyperlinkpagefilterscontentrecord                     {                         hyperlinkpagefilterspartrecord = record,                         hyperlinkpagefilterrecord = hyperlinkpagefilter                     });                 }             }              public ienumerable<hyperlinkpagefilterrecord> gethyperlinkpagefilters()             {                 return _hyperlinkpagefilterrepository.table.tolist();             } 

migration:

    public int updatefrom11()     {         schemabuilder.createtable("hyperlinkpagefilterspartrecord",         table => table             .contentpartrecord()         );          schemabuilder.createtable("hyperlinkpagefilterrecord",         table => table             .column<int>("id", column => column.primarykey().identity())             .column<int>("pageid")         );          schemabuilder.createtable("hyperlinkpagefilterscontentrecord",             table => table                 .column<int>("id", column => column.primarykey().identity())                 .column<int>("hyperlinkpagefilterspartrecord_id")                 .column<int>("hyperlinkpagefilterrecord_id")             );         return 12;     }        public int updatefrom12() {         contentdefinitionmanager.altertypedefinition("hyperlinkpagefilterspart", builder => builder             .displayedas("hyperlink page filters")             .withpart("hyperlinkpagefilterspart")             );         return 13;     }     public int updatefrom13()     {         contentdefinitionmanager.alterpartdefinition(             "hyperlinkpagefilterspart",             builder => builder.attachable());         return 14;     }     } } 

and lastly... driver don't hit...

namespace mylib.orchard.hyperlinkitemmanager.drivers {     [usedimplicitly]     public class hyperlinkpagefilterspartdriver : contentpartdriver<hyperlinkpagefilterspart>     {         private readonly ihyperlinkpagefiltersservice _hyperlinkpagefiltersservice;         private icontentmanager _contentmanager;          //private const string templatename = "parts/hyperlinkpagefilters";          public hyperlinkpagefilterspartdriver(ihyperlinkpagefiltersservice hyperlinkpagefiltersservice, icontentmanager contentmanager)         {             _hyperlinkpagefiltersservice = hyperlinkpagefiltersservice;             _contentmanager = contentmanager;         }          protected override string prefix         {             { return "hyperlinkpagefilters"; }         }          protected override driverresult display(hyperlinkpagefilterspart part,string displaytype,dynamic shapehelper)         {              return contentshape("parts_hyperlinkpagefilters", () => shapehelper.parts_hyperlinkpagefilters(                                 contentpart: part,                                 hyperlinkpagefilters: part.hyperlinkpagefilters));         }          protected override driverresult editor(hyperlinkpagefilterspart part, dynamic shapehelper)         {               return contentshape("parts_hyperlinkpagefilters_edit",                     () => shapehelper.editortemplate(                         templatename: "parts.hyperlinkpagefilters.edit",                         model: buildeditorviewmodel(part),                         prefix: prefix));         }          protected override driverresult editor(hyperlinkpagefilterspart part, iupdatemodel updater, dynamic shapehelper)         {              var model = new hyperlinkpagefilterseditviewmodel();             updater.tryupdatemodel(model, prefix, null, null);              if (part.contentitem.id != 0)             {                 _hyperlinkpagefiltersservice.updatehyperlinkpagefiltersforcontentitem(                     part.contentitem, model.hyperlinkpagefilters);             }              return editor(part, shapehelper);         }          private hyperlinkpagefilterseditviewmodel buildeditorviewmodel(hyperlinkpagefilterspart part)         {              //get pages             var pages = _contentmanager.query("pages");              //get pagesfilters              //check pages              var itemrewards = part.hyperlinkpagefilters.tolookup(r => r.id);             return new hyperlinkpagefilterseditviewmodel             {                 hyperlinkpagefilters = _hyperlinkpagefiltersservice.gethyperlinkpagefilters().select(                     r => new hyperlinkpagefilterentry                     {                         hyperlinkpagefilter = r,                         ischecked = itemrewards.contains(r.id)                     }).tolist()             };         }     } } 

handler:

namespace mylib.orchard.hyperlinkitemmanager.handlers {     public class hyperlinkpagefiltersparthandler : contenthandler {         public hyperlinkpagefiltersparthandler(irepository<hyperlinkpagefilterspartrecord> repository) {             filters.add(storagefilter.for(repository));         }     } } 


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -