예제 #1
0
        // Umbraco.Code.MapAll -Blueprints
        private void Map(IContentTypeBase source, ContentTypeBasic target, string entityType)
        {
            target.Udi          = Udi.Create(entityType, source.Key);
            target.Alias        = source.Alias;
            target.CreateDate   = source.CreateDate;
            target.Description  = source.Description;
            target.Icon         = source.Icon;
            target.IconFilePath = target.IconIsClass
                ? string.Empty
                : $"{_globalSettings.GetBackOfficePath(_hostingEnvironment).EnsureEndsWith("/")}images/umbraco/{source.Icon}";

            target.Trashed           = source.Trashed;
            target.Id                = source.Id;
            target.IsContainer       = source.IsContainer;
            target.IsElement         = source.IsElement;
            target.Key               = source.Key;
            target.Name              = source.Name;
            target.ParentId          = source.ParentId;
            target.Path              = source.Path;
            target.Thumbnail         = source.Thumbnail;
            target.ThumbnailFilePath = target.ThumbnailIsClass
                ? string.Empty
                : _hostingEnvironment.ToAbsolute("~/umbraco/images/thumbnails/" + source.Thumbnail);
            target.UpdateDate = source.UpdateDate;
        }
예제 #2
0
        public ContentTypeBasic Resolve(TSource source, TDestination destination, ContentTypeBasic destMember, ResolutionContext context)
        {
            //TODO: We can resolve the UmbracoContext from the IValueResolver options!
            // OMG
            if (HttpContext.Current != null && UmbracoContext.Current != null && UmbracoContext.Current.Security.CurrentUser != null &&
                UmbracoContext.Current.Security.CurrentUser.AllowedSections.Any(x => x.Equals(Constants.Applications.Settings)))
            {
                ContentTypeBasic contentTypeBasic;
                if (source is IContent content)
                {
                    contentTypeBasic = Mapper.Map <IContentType, ContentTypeBasic>(content.ContentType);
                }
                else if (source is IMedia media)
                {
                    contentTypeBasic = Mapper.Map <IMediaType, ContentTypeBasic>(media.ContentType);
                }
                else
                {
                    throw new NotSupportedException($"Expected TSource to be IContent or IMedia, got {typeof(TSource).Name}.");
                }

                return(contentTypeBasic);
            }
            //no access
            return(null);
        }
예제 #3
0
        public ContentTypeBasic Resolve(TSource source, TDestination destination, ContentTypeBasic destMember, ResolutionContext context)
        {
            // TODO: We can resolve the UmbracoContext from the IValueResolver options!
            // OMG
            if (HttpContext.Current != null && Current.UmbracoContext != null && Current.UmbracoContext.Security.CurrentUser != null &&
                Current.UmbracoContext.Security.CurrentUser.AllowedSections.Any(x => x.Equals(Constants.Applications.Settings)))
            {
                var contentType      = _contentTypeBaseServiceProvider.GetContentTypeOf(source);
                var contentTypeBasic = Mapper.Map <IContentTypeComposition, ContentTypeBasic>(contentType);

                return(contentTypeBasic);
            }
            //no access
            return(null);
        }
예제 #4
0
 // Umbraco.Code.MapAll -Blueprints
 private static void Map(IContentTypeBase source, ContentTypeBasic target, string entityType)
 {
     target.Udi         = Udi.Create(entityType, source.Key);
     target.Alias       = source.Alias;
     target.CreateDate  = source.CreateDate;
     target.Description = source.Description;
     target.Icon        = source.Icon;
     target.Id          = source.Id;
     target.IsContainer = source.IsContainer;
     target.IsElement   = source.IsElement;
     target.Key         = source.Key;
     target.Name        = source.Name;
     target.ParentId    = source.ParentId;
     target.Path        = source.Path;
     target.Thumbnail   = source.Thumbnail;
     target.Trashed     = source.Trashed;
     target.UpdateDate  = source.UpdateDate;
 }
예제 #5
0
 // no MapAll - uses the IContentTypeBase map method, which has MapAll
 private void Map(IMemberType source, ContentTypeBasic target, MapperContext context) =>
 Map(source, target, Constants.UdiEntityType.MemberType);
예제 #6
0
 // no MapAll - uses the IContentTypeBase map method, which has MapAll
 private static void Map(IMediaType source, ContentTypeBasic target, MapperContext context)
 {
     Map(source, target, Constants.UdiEntityType.MediaType);
 }
예제 #7
0
 // no MapAll - uses the IContentTypeBase map method, which has MapAll
 private static void Map(IContentTypeComposition source, ContentTypeBasic target, MapperContext context)
 {
     Map(source, target, Constants.UdiEntityType.MemberType);
 }
예제 #8
0
 // no MapAll - uses the IContentTypeBase map method, which has MapAll
 private void Map(IContentType source, ContentTypeBasic target, MapperContext context)
 {
     Map(source, target, Constants.UdiEntityType.DocumentType);
 }
예제 #9
0
    /// <summary>
    ///     Setup all standard member data for test
    /// </summary>
    private Member SetupMemberTestData(
        out MemberSave fakeMemberData,
        out MemberDisplay memberDisplay,
        ContentSaveAction contentAction)
    {
        // arrange
        var memberType = MemberTypeBuilder.CreateSimpleMemberType();
        var member     = MemberBuilder.CreateSimpleMember(memberType, "Test Member", "*****@*****.**", "123", "test");
        var memberId   = 123;

        member.Id = memberId;

        // TODO: replace with builder for MemberSave and MemberDisplay
        fakeMemberData = new MemberSave
        {
            Id            = memberId,
            SortOrder     = member.SortOrder,
            ContentTypeId = memberType.Id,
            Key           = member.Key,
            Password      = new ChangingPasswordModel {
                Id = 456, NewPassword = member.RawPasswordValue, OldPassword = null
            },
            Name                  = member.Name,
            Email                 = member.Email,
            Username              = member.Username,
            PersistedContent      = member,
            PropertyCollectionDto = new ContentPropertyCollectionDto(),
            Groups                = new List <string>(),

            // Alias = "fakeAlias",
            ContentTypeAlias = member.ContentTypeAlias,
            Action           = contentAction,
            Icon             = "icon-document",
            Path             = member.Path,
        };

        memberDisplay = new MemberDisplay
        {
            Id            = memberId,
            SortOrder     = member.SortOrder,
            ContentTypeId = memberType.Id,
            Key           = member.Key,
            Name          = member.Name,
            Email         = member.Email,
            Username      = member.Username,

            // Alias = "fakeAlias",
            ContentTypeAlias = member.ContentTypeAlias,
            ContentType      = new ContentTypeBasic(),
            ContentTypeName  = member.ContentType.Name,
            Icon             = fakeMemberData.Icon,
            Path             = member.Path,
            Tabs             = new List <Tab <ContentPropertyDisplay> >
            {
                new()
                {
                    Alias      = "test",
                    Id         = 77,
                    Properties = new List <ContentPropertyDisplay>
                    {
                        new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}login" },
                        new() { Alias = $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}email" },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}password",
                        },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}membergroup",
                        },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}failedPasswordAttempts",
                        },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}approved",
                        },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lockedOut",
                        },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLockoutDate",
                        },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastLoginDate",
                        },
                        new()
                        {
                            Alias =
                                $"{Constants.PropertyEditors.InternalGenericPropertiesPrefix}lastPasswordChangeDate",
                        },
                    },
                },
            },
        };

        return(member);
    }