IContentManager or IRepository, perhaps both? Love your thoughts...

Topics: General, Writing modules
Feb 19, 2015 at 10:03 PM
Hey All, I'm wishing to create a custom Module[s] for a hopefully simple, Employee Timesheet.

I wish to attach some further details to the User [name, contact, age etc. + Address Table as well] and obviously several new Tables [Hours / Projects, etc.].

So, I was wondering if I should use a combination of IContentManager and IRepository [...as in, for the User info i'm pretty sure I could accomplish everything with IContentManager - but with the rest, probably a Service / Repository] or stick to just one? I've read thoughts on both, but am still a little in the dark for which way to jump?

Any help you could give would be really appreciated, perhaps even a recommended module I could investigate for learning/best practices [I loved the HungaryOrchard.Demo - which BTW used a IRep / Service].
Thanks a lot for your time, Liv
Feb 20, 2015 at 4:06 PM
I believe you meant OrchardHUN.TrainingDemo :-). Indeed that demonstrates both. The basic rules would be:
  • Use content items (and content parts, possibly with content part records) when you want to store user-facing content, including when you want to add data to existing content types' items, and/or when you need what content items provide OOTB (soft deletes, versioning, built-in editors, listings, import/export...).
  • Use simple records (and access them through IRepository) when you want to store something not classifiable as "content" or you don't need anything content items do already.
Feb 25, 2015 at 1:56 AM
Oops, indeed! Thanks Piedone, so it seems I will go with IContentManager; really appreciate the clarification ;)