Exemple #1
0
        public IMedia BuildEntity(ContentVersionDto dto)
        {
            var media = new Models.Media(dto.ContentDto.NodeDto.Text, dto.ContentDto.NodeDto.ParentId, _contentType)
            {
                Id  = _id,
                Key =
                    dto.ContentDto.NodeDto.UniqueId.HasValue
                                   ? dto.ContentDto.NodeDto.UniqueId.Value
                                   : _id.ToGuid(),
                Path       = dto.ContentDto.NodeDto.Path,
                CreatorId  = dto.ContentDto.NodeDto.UserId.Value,
                Level      = dto.ContentDto.NodeDto.Level,
                ParentId   = dto.ContentDto.NodeDto.ParentId,
                SortOrder  = dto.ContentDto.NodeDto.SortOrder,
                Trashed    = dto.ContentDto.NodeDto.Trashed,
                CreateDate = dto.ContentDto.NodeDto.CreateDate,
                UpdateDate = dto.VersionDate,
                Version    = dto.VersionId
            };

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            media.ResetDirtyProperties(false);
            return(media);
        }
Exemple #2
0
        public static IMedia BuildEntity(ContentVersionDto dto, IMediaType contentType)
        {
            var media = new Models.Media(dto.ContentDto.NodeDto.Text, dto.ContentDto.NodeDto.ParentId, contentType);

            try
            {
                media.DisableChangeTracking();

                media.Id         = dto.NodeId;
                media.Key        = dto.ContentDto.NodeDto.UniqueId;
                media.Path       = dto.ContentDto.NodeDto.Path;
                media.CreatorId  = dto.ContentDto.NodeDto.UserId.Value;
                media.Level      = dto.ContentDto.NodeDto.Level;
                media.ParentId   = dto.ContentDto.NodeDto.ParentId;
                media.SortOrder  = dto.ContentDto.NodeDto.SortOrder;
                media.Trashed    = dto.ContentDto.NodeDto.Trashed;
                media.CreateDate = dto.ContentDto.NodeDto.CreateDate;
                media.UpdateDate = dto.VersionDate;
                media.Version    = dto.VersionId;
                //on initial construction we don't want to have dirty properties tracked
                // http://issues.umbraco.org/issue/U4-1946
                media.ResetDirtyProperties(false);
                return(media);
            }
            finally
            {
                media.EnableChangeTracking();
            }
        }
        /// <summary>
        /// Builds an IMedia item from a dto and content type.
        /// </summary>
        public static Models.Media BuildEntity(ContentDto dto, IMediaType contentType)
        {
            var nodeDto           = dto.NodeDto;
            var contentVersionDto = dto.ContentVersionDto;

            var content = new Models.Media(nodeDto.Text, nodeDto.ParentId, contentType);

            try
            {
                content.DisableChangeTracking();

                content.Id        = dto.NodeId;
                content.Key       = nodeDto.UniqueId;
                content.VersionId = contentVersionDto.Id;

                // fixme missing names?

                content.Path      = nodeDto.Path;
                content.Level     = nodeDto.Level;
                content.ParentId  = nodeDto.ParentId;
                content.SortOrder = nodeDto.SortOrder;
                content.Trashed   = nodeDto.Trashed;

                content.CreatorId  = nodeDto.UserId ?? Constants.Security.UnknownUserId;
                content.WriterId   = contentVersionDto.UserId ?? Constants.Security.UnknownUserId;
                content.CreateDate = nodeDto.CreateDate;
                content.UpdateDate = contentVersionDto.VersionDate;

                // reset dirty initial properties (U4-1946)
                content.ResetDirtyProperties(false);
                return(content);
            }
            finally
            {
                content.EnableChangeTracking();
            }
        }