Beispiel #1
0
        // Umbraco.Code.MapAll -AllowPreview -Errors -PersistedContent
        private void Map(IContent source, ContentItemDisplay target, MapperContext context)
        {
            target.AllowedActions   = GetActions(source);
            target.AllowedTemplates = GetAllowedTemplates(source);
            target.ContentApps      = _commonMapper.GetContentApps(source);
            target.ContentTypeId    = source.ContentType.Id;
            target.ContentTypeKey   = source.ContentType.Key;
            target.ContentTypeAlias = source.ContentType.Alias;
            target.ContentTypeName  = _localizedTextService.UmbracoDictionaryTranslate(source.ContentType.Name);
            target.DocumentType     = _commonMapper.GetContentType(source, context);
            target.Icon             = source.ContentType.Icon;
            target.Id                = source.Id;
            target.IsBlueprint       = source.Blueprint;
            target.IsChildOfListView = DetermineIsChildOfListView(source, context);
            target.IsContainer       = source.ContentType.IsContainer;
            target.IsElement         = source.ContentType.IsElement;
            target.Key               = source.Key;
            target.Owner             = _commonMapper.GetOwner(source, context);
            target.ParentId          = source.ParentId;
            target.Path              = source.Path;
            target.SortOrder         = source.SortOrder;
            target.TemplateAlias     = GetDefaultTemplate(source);
            target.TemplateId        = source.TemplateId ?? default;
            target.Trashed           = source.Trashed;
            target.TreeNodeUrl       = _commonMapper.GetTreeNodeUrl <ContentTreeController>(source);
            target.Udi               = Udi.Create(source.Blueprint ? Constants.UdiEntityType.DocumentBlueprint : Constants.UdiEntityType.Document, source.Key);
            target.UpdateDate        = source.UpdateDate;
            target.Updater           = _commonMapper.GetCreator(source, context);
            target.Urls              = GetUrls(source);
            target.Variants          = _contentVariantMapper.Map(source, context);

            target.ContentDto            = new ContentPropertyCollectionDto();
            target.ContentDto.Properties = context.MapEnumerable <Property, ContentPropertyDto>(source.Properties);
        }
        // Umbraco.Code.MapAll -AllowPreview -Errors -PersistedContent
        private void Map(IContent source, ContentItemDisplay target, MapperContext context)
        {
            // Both GetActions and DetermineIsChildOfListView use parent, so get it once here
            // Parent might already be in context, so check there before using content service
            IContent parent;

            if (context.Items.TryGetValue("Parent", out var parentObj) &&
                parentObj is IContent typedParent)
            {
                parent = typedParent;
            }
            else
            {
                parent = _contentService.GetParent(source);
            }

            target.AllowedActions   = GetActions(source, parent, context);
            target.AllowedTemplates = GetAllowedTemplates(source);
            target.ContentApps      = _commonMapper.GetContentApps(source);
            target.ContentTypeId    = source.ContentType.Id;
            target.ContentTypeKey   = source.ContentType.Key;
            target.ContentTypeAlias = source.ContentType.Alias;
            target.ContentTypeName  = _localizedTextService.UmbracoDictionaryTranslate(source.ContentType.Name);
            target.DocumentType     = _commonMapper.GetContentType(source, context);
            target.Icon             = source.ContentType.Icon;
            target.Id                = source.Id;
            target.IsBlueprint       = source.Blueprint;
            target.IsChildOfListView = DetermineIsChildOfListView(source, parent, context);
            target.IsContainer       = source.ContentType.IsContainer;
            target.IsElement         = source.ContentType.IsElement;
            target.Key               = source.Key;
            target.Owner             = _commonMapper.GetOwner(source, context);
            target.ParentId          = source.ParentId;
            target.Path              = source.Path;
            target.SortOrder         = source.SortOrder;
            target.TemplateAlias     = GetDefaultTemplate(source);
            target.TemplateId        = source.TemplateId ?? default;
            target.Trashed           = source.Trashed;
            target.TreeNodeUrl       = _commonMapper.GetTreeNodeUrl <ContentTreeController>(source);
            target.Udi               = Udi.Create(source.Blueprint ? Constants.UdiEntityType.DocumentBlueprint : Constants.UdiEntityType.Document, source.Key);
            target.UpdateDate        = source.UpdateDate;
            target.Updater           = _commonMapper.GetCreator(source, context);
            target.Urls              = GetUrls(source);
            target.Variants          = _contentVariantMapper.Map(source, context);

            target.ContentDto            = new ContentPropertyCollectionDto();
            target.ContentDto.Properties = context.MapEnumerable <Property, ContentPropertyDto>(source.Properties);
        }