Tutorial 3 - Using inheritance and basic types

In this tutorial we will look at how we can configure our classes to use inheritance using attribute configuration.
When you start to build you models you will want to group common properties in to a base class and make you other models inherit from it. For example in our simple solution most of our models use the "Name" field and have the items URL and ID. We extracted this into a separate classes:
DPModel – represents basic CMS models. You can inherit your model from this one if you aren’t planing to create public page for your entity.

     /// <summary> 
     /// Base class for entity models
     /// </summary> 
     [Ignore]
     public class DPModel : BaseEntity, IDPModel
     {
         /// <summary> 
         /// Gets or sets the name
         /// </summary> 
         public string Name { get; set; }
         /// <summary> 
         /// Gets or sets a value of entity type identifier
         /// </summary> 
         public int EntityTypeId { get; set; }
         /// <summary> 
         /// Gets or sets the parent entity identifier
         /// </summary> 
         public int? ParentId { get; set; }
         /// <summary> 
         /// Gets or sets the description
         /// </summary> 
         public string Description { get; set; }
         /// <summary> 
         /// Gets or sets the display order
         /// </summary> 
         public int DisplayOrder { get; set; }
         /// <summary> 
         /// Gets or sets the customer of instance update
         /// </summary> 
         public int? CustomerIdOfLastChange { get; set; }
         /// <summary> 
         /// Gets or sets the external identifier
         /// </summary> 
         public string ExtId { get; set; }
         /// <summary> 
         /// Gets or sets the date and time of instance update
         /// </summary> 
         public DateTime UpdatedOnUtc { get; set; }
         /// <summary> 
         /// Gets or sets a value indicating whether the entity is subject to ACL
         /// </summary> 
         public bool SubjectToAcl { get; set; }
     }
 

Now that we have the base type defined we can review Public Page class which inherit from DPModel: DPPublicPageModel - represents basic CMS model for public page. You can inherit your model from this one if you planing to create public page. This model add SEO atts to the SEO admin tab and Published checkbox to the published admin tab. In this model we use special property names UrlRecord. Auto-mapping in EntityModelService will populate the UrlRecord property with the Url(slug) of the entity.


     /// <summary> 
     /// Represents a public page model
     /// </summary> 
     [Ignore]
     public class DPPublicPageModel : DPModel
     {
         /// <summary> 
         /// Gets or sets the meta keywords
         /// </summary> 
         [Group("SEO")]
         public string MetaKeywords { get; set; }
         /// <summary> 
         /// Gets or sets the meta description
         /// </summary> 
         [Group("SEO")]
         public string MetaDescription { get; set; }
         /// <summary> 
         /// Gets or sets the meta title
         /// </summary> 
         [Group("SEO")]
         public string MetaTitle { get; set; }
         /// <summary> 
         /// Gets or sets the url record
         /// </summary> 
         [Group("SEO")]
         [UrlRecord]
         public string UrlRecord { get; set; }
         /// <summary> 
         /// Gets or sets a value indicating whether the entity is published
         /// </summary> 
         [Group("Published")]
         public bool Published { get; set; }
         /// <summary> 
         /// Gets or sets the text
         /// </summary> 
         [EditorTemplate("RichEditor")]
         [Localazible]
         public string Text { get; set; }
     }
 

DPPublicNavigationPageModel - represents basic CMS model for content public page with navigation attributes. You can inherit your model from this one if you need to include your page to top/myaccount/footer menus or sitemap.


     /// <summary> 
     /// Represents a public content page
     /// </summary> 
     [Ignore]
     public class DPPublicContentPageModel : DPPublicPageModel, IDPThumbnailImage
     {
         /// <summary> 
         /// Gets or sets the thubnail picture
         /// </summary> 
         public Picture ThumbnailImage { get; set; }
         /// <summary> 
         /// Gets or sets the published DateTime
         /// </summary> 
         [EditorTemplate("Date")]
         [Group("Published")]
         public DateTime? PublishDateTime { get; set; }
         /// <summary> 
         /// Gets or sets the available start date and time
         /// </summary> 
         [Group("Published")]
         public DateTime? AvailableStartDateTimeUtc { get; set; }
         /// <summary> 
         /// Gets or sets the available end date and time
         /// </summary> 
         [Group("Published")]
         public DateTime? AvailableEndDateTimeUtc { get; set; }
     }
 

DPPublicContentPageModel - represents basic CMS model for content public page model. You can inherit your model from this if you need to use ThumbnailImage or your would like to specify AvailableStartDateTimeUtc/AvailableEndDateTimeUtc atts.


     /// <summary> 
     /// Represents a public content page with navigation atts
     /// </summary> 
     [Ignore]
     public class DPPublicNavigationPageModel : DPPublicContentPageModel
     {
         /// <summary> 
         /// Gets or sets the value indicating whether this page should be included in sitemap
         /// </summary>
         [Group("Navigation")]
         public bool IncludeInSitemap { get; set; }
         /// <summary> 
         /// Gets or sets the value indicating whether this page should be included in top menu
         /// </summary> 
         [Group("Navigation")]
         public bool IncludeInTopMenu { get; set; }
         /// <summary> 
         /// Gets or sets the value indicating whether this page should be my account menu
         /// </summary> 
         [Group("Navigation")]
         public bool IncludeInMyAccountMenu { get; set; }
         /// <summary> 
         /// Gets or sets the value indicating whether this page should be included in footer (column 1)
         /// </summary> 
         [Group("Navigation")]
         public bool IncludeInFooterColumn1 { get; set; }
         /// <summary> 
         /// Gets or sets the value indicating whether this page should be included in footer (column 2)
         /// </summary> 
         [Group("Navigation")]
         public bool IncludeInFooterColumn2 { get; set; }
         /// <summary> 
         /// Gets or sets the value indicating whether this page should be included in footer (column 3)
         /// </summary> 
         [Group("Navigation")]
         public bool IncludeInFooterColumn3 { get; set; }
     }
 

This completes the this tutorial, we have seen how which basic classes we can use in our code