DEV Community

Discussion on: Kentico 12: Design Patterns Part 20 - Choosing a Solution Architecture

Collapse
 
peterotmar profile image
peterotmar

Great post Sean, thanks for explaining in detail.
In your Sandbox.Core, how would you represent data such as PageAttachment. We use BasePageData for all other "Page" things such as NodeId, Guid, etc. including IList where PageAttachment class has a property of Kentico.Content.Web.Mvc.IPageAttachmentUrl. Do you have any tips on how to set it up in core without referencing Kentico libs?
Thanks

Collapse
 
seangwright profile image
Sean G. Wright

I handle page attachments and media library files the same way I handle Page Type data.

I create POCO class that represents the minimum about of information the presentation layer needs about that object and project the *Info type into it within my data access layer.

I typically have a ImageContent type and a MediaContent type. These have the Guid and ID fields of the database objects they represent and other important values like URLs and Labels. Images have width/height properties.

But the key part is that I'm returning a limited set of values and only working with the Kentico types in the data access implementation methods.

This makes my caching slimmer and allows me to adjust my data access implementation more easily (returning an AttachmentInfo makes it hard to return additional metadata from an external system, for example).

Specially to your question, the IPageAttachmentUrl are resolved and turned into a string URL property on my MediaContent type in the data access implementation.