commodore73

PageDataField Group Field Model

Jul 23rd, 2020
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace Root.Core.Models.GlobalFields.PageData
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.  
  6.     using Deliverystack.Core.Models.Repositories;
  7.  
  8.     using Root.Core.Models.Controls;
  9.     using Root.Core.Models.Entries.Author;
  10.     using Root.Core.Models.Fields;
  11.  
  12.     public class PageDataField
  13.     {
  14.         //require repository
  15.         private PageDataField()
  16.         {
  17.         }
  18.  
  19.         public PageDataField(IRepository repository)
  20.         {
  21.             Repository = repository;
  22.         }
  23.        
  24.         public IRepository Repository { get; set; }
  25.        
  26.         public string Title { get; set; }
  27.  
  28.  
  29.         private string _shortTitle = null;
  30.  
  31.         public string ShortTitle
  32.         {
  33.             get
  34.             {
  35.                 if (String.IsNullOrEmpty(_shortTitle))
  36.                 {
  37.                     _shortTitle = Title;
  38.                 }
  39.  
  40.                 return _shortTitle;
  41.             }
  42.  
  43.             set
  44.             {
  45.                 _shortTitle = value;
  46.             }
  47.         }
  48.         public string Keywords { get; set; }
  49.         public string Description { get; set; }
  50.  
  51.         public List<ReferenceField<AuthorEntry>> Authors { get; set; }
  52. //public List<AuthorEntry> Authors { get; set; }
  53.  
  54.         // nullable to support deserialization of empty value
  55.         public ChangeFrequency? ChangeFrequency { get; set; } = Controls.ChangeFrequency.Never;
  56.  
  57.         // nullable to support deserialization of empty value
  58.         public double? Priority { get; set; } = double.MinValue;
  59.  
  60.         public bool ExcludeFromSitemap { get; set; }
  61.  
  62.         public string View { get; set; }
  63.  
  64.         public string PartialView { get; set; }
  65.     }
  66. }
  67.  
  68. //TODO: public List<Entry> Children { get; set; }
  69.  
  70. //TODO: Initialize() could do the following for all List<T> where T : EntryModel?
  71.  
  72. // alternative approach where Authors is List<AuthorEntry>
  73. // in which case Entries have only UID and CTUID.
  74. // to implement as a property, pass repository some other way
  75.  
  76. /*        public AuthorEntry[] GetAuthors(IRepository repository)
  77.         {
  78.             if (Authors == null || Authors.Count < 1)
  79.             {
  80.                 return new AuthorEntry[0];
  81.             }
  82.  
  83.             if (!_authorsFetched)
  84.             {
  85.                 for (int i = 0; i < Authors.Count; i++)
  86.                 {
  87.                     Authors[i] =
  88.                         repository.Get<AuthorEntry>(Authors[i].EntryUid, Authors[i].ContentTypeUid);
  89.                 }
  90.             }
  91.  
  92.             return Authors.ToArray();
  93.         }*/
  94.  
  95.  
RAW Paste Data