Example #1
0
        // todo: check if this call could be replaced with the normal ContentTypeController.Get to prevent redundant code
        public IEnumerable<object> GetContentTypesWithStatus()
        {
            // 2016-09-08 2dm - changed to use all templates, because of https://github.com/2sic/2sxc/issues/831
            var availableTemplates = GetAllTemplates().ToList();// GetVisibleTemplates();
            var visTemplates = availableTemplates.Where(t => !t.IsHidden).ToList();
            var mdCache = TemplateDataSource().Cache;
            var ctc = new ContentTypeController();
            var ser = new Serializer();

            return GetAvailableContentTypes(Settings.AttributeSetScope)
                .Where(p => availableTemplates.Any(t => t.ContentTypeStaticName == p.StaticName)) // must exist in at least 1 template
                .OrderBy(p => p.Name)
                .Select(p => new
                {
                    p.StaticName,
                    p.Name,
                    IsHidden = !(visTemplates.Any(t => t.ContentTypeStaticName == p.StaticName)), // must check if *any* template is visible, otherise tell the UI that it's hidden
                    Metadata = ser.Prepare(ctc.GetMetadata(p, mdCache))
                });
        }