Example #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sfContent">The sf content.</param>
        public ListItemModel(ListItem sfContent)
            : base(sfContent)
        {
            if (sfContent != null)
            {
                Content = sfContent.Content;
                Slug    = sfContent.UrlName;
                Ordinal = sfContent.Ordinal;
                Status  = sfContent.Status;
                Active  = sfContent.Status == ContentLifecycleStatus.Live &&
                          sfContent.Visible;

                if (sfContent.Parent != null)
                {
                    Parent = new ParentModel
                    {
                        Id          = sfContent.Parent.Id,
                        Title       = sfContent.Parent.Title,
                        Description = sfContent.Parent.Description,
                        Slug        = sfContent.Parent.UrlName
                    };
                }

                //POPULATE TAXONOMIES TO LIST
                Categories = sfContent.GetTaxa("Category");
                Tags       = sfContent.GetTaxa("Tags");

                // Store original content
                OriginalContent = sfContent;
            }
        }
Example #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sfContent">The sf content.</param>
        public TaxonModel(ITaxon sfContent)
        {
            if (sfContent != null)
            {
                Id               = sfContent.Id;
                Title            = sfContent.Title;
                Description      = sfContent.Description;
                ShowInNavigation = sfContent.ShowInNavigation;
                Slug             = sfContent.UrlName;
                Ordinal          = sfContent.Ordinal;
                LastModified     = sfContent.LastModified;
                Classification   = sfContent.Taxonomy.Name;

                //HANDLE HIERARCHY IF APPLICABLE
                IsHierarchy = sfContent is HierarchicalTaxon;
                if (IsHierarchy)
                {
                    var item = sfContent as HierarchicalTaxon;
                    if (item.Parent != null)
                    {
                        Parent = new ParentModel
                        {
                            Id          = item.Parent.Id,
                            Title       = item.Parent.Title,
                            Description = item.Parent.Description,
                            Ordinal     = item.Parent.Ordinal,
                            Slug        = item.Parent.UrlName
                        };
                    }
                }

                // Store original content
                OriginalContent = sfContent;
            }
        }
Example #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sfContent">The sf content.</param>
        public DepartmentModel(HierarchicalTaxon sfContent)
        {
            var manager = TaxonomyManager.GetManager();

            Id               = sfContent.Id;
            Title            = sfContent.Title;
            Description      = sfContent.Description;
            FullUrl          = sfContent.FullUrl;
            Ordinal          = sfContent.Ordinal;
            RenderAsLink     = sfContent.RenderAsLink;
            ShowInNavigation = sfContent.ShowInNavigation;
            TaxonName        = sfContent.Taxonomy.TaxonName;
            Slug             = sfContent.UrlName;
            LastModified     = sfContent.LastModified;

            //STORE PARENT DETAILS IF APPLICABLE
            if (sfContent.Parent != null)
            {
                Parent = new ParentModel
                {
                    Id          = sfContent.Parent.Id,
                    Title       = sfContent.Parent.Title,
                    Description = sfContent.Parent.Description,
                    Ordinal     = sfContent.Parent.Ordinal,
                    Slug        = sfContent.Parent.UrlName
                };
            }

            //BUILD CHILDREN CATEGORIES
            Subtaxa = new List <DepartmentModel>();
            sfContent.Subtaxa.ToList().ForEach(c =>
                                               Subtaxa.Add(new DepartmentModel(c)));

            //GET NUMBER OF ITEMS IN CATEGORY
            Count = (int)manager.GetTaxonItemsCount(sfContent.Id, ContentLifecycleStatus.Live);

            // Store original content
            OriginalContent = sfContent;
        }