Пример #1
0
        // helpers

        private void MapUserGroupBasic(UserGroupBasic target, IEnumerable <string> sourceAllowedSections, int?sourceStartContentId, int?sourceStartMediaId, MapperContext context)
        {
            var allSections = _sectionService.GetSections();

            target.Sections = context.MapEnumerable <ISection, Section>(allSections.Where(x => sourceAllowedSections.Contains(x.Alias)));

            if (sourceStartMediaId > 0)
            {
                target.MediaStartNode = context.Map <EntityBasic>(_entityService.Get(sourceStartMediaId.Value, UmbracoObjectTypes.Media));
            }
            else if (sourceStartMediaId == -1)
            {
                target.MediaStartNode = CreateRootNode(_textService.Localize("media/mediaRoot"));
            }

            if (sourceStartContentId > 0)
            {
                target.ContentStartNode = context.Map <EntityBasic>(_entityService.Get(sourceStartContentId.Value, UmbracoObjectTypes.Document));
            }
            else if (sourceStartContentId == -1)
            {
                target.ContentStartNode = CreateRootNode(_textService.Localize("content/contentRoot"));
            }

            if (target.Icon.IsNullOrWhiteSpace())
            {
                target.Icon = "icon-users";
            }
        }
        private void MapUserGroupBasic(ServiceContext services, dynamic group, UserGroupBasic display)
        {
            var allSections = services.SectionService.GetSections();

            display.Sections = allSections.Where(x => Enumerable.Contains(group.AllowedSections, x.Alias)).Select(Mapper.Map <ContentEditing.Section>);

            if (group.StartMediaId > 0)
            {
                display.MediaStartNode = Mapper.Map <EntityBasic>(
                    services.EntityService.Get(group.StartMediaId, UmbracoObjectTypes.Media));
            }
            else if (group.StartMediaId == -1)
            {
                //create the root node
                display.MediaStartNode = RootNode(services.TextService.Localize("media/mediaRoot"));
            }

            if (group.StartContentId > 0)
            {
                display.ContentStartNode = Mapper.Map <EntityBasic>(
                    services.EntityService.Get(group.StartContentId, UmbracoObjectTypes.Document));
            }
            else if (group.StartContentId == -1)
            {
                //create the root node
                display.ContentStartNode = RootNode(services.TextService.Localize("content/contentRoot"));
            }

            if (display.Icon.IsNullOrWhiteSpace())
            {
                display.Icon = "icon-users";
            }
        }
Пример #3
0
 // Umbraco.Code.MapAll -ContentStartNode -UserCount -MediaStartNode -Key -Sections
 // Umbraco.Code.MapAll -Notifications -Udi -Trashed -AdditionalData
 private void Map(IReadOnlyUserGroup source, UserGroupBasic target, MapperContext context)
 {
     target.Alias    = source.Alias;
     target.Icon     = source.Icon;
     target.Id       = source.Id;
     target.Name     = source.Name;
     target.ParentId = -1;
     target.Path     = "-1," + source.Id;
     MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context);
 }
Пример #4
0
        // Umbraco.Code.MapAll -ContentStartNode -MediaStartNode -Sections -Notifications
        // Umbraco.Code.MapAll -Udi -Trashed -AdditionalData -IsSystemUserGroup
        private void Map(IUserGroup source, UserGroupBasic target, MapperContext context)
        {
            target.Alias             = source.Alias;
            target.Icon              = source.Icon;
            target.Id                = source.Id;
            target.Key               = source.Key;
            target.Name              = source.Name;
            target.ParentId          = -1;
            target.Path              = "-1," + source.Id;
            target.UserCount         = source.UserCount;
            target.IsSystemUserGroup = source.IsSystemUserGroup();

            MapUserGroupBasic(target, source.AllowedSections, source.StartContentId, source.StartMediaId, context);
        }