Beispiel #1
0
        /// <summary>
        /// Save Item Image Meta Data
        /// </summary>
        /// <param name="image">Image</param>
        /// <param name="userId">User Identifier</param>
        /// <returns>Item Image</returns>
        public ItemImage SaveItem(ItemImageMetaData image, Guid userId)
        {
            if (null == image)
            {
                throw new ArgumentNullException("image");
            }

            if (Guid.Empty == image.Identifier)
            {
                throw new ArgumentException("Identifer");
            }

            if (Guid.Empty == userId)
            {
                throw new ArgumentException("Identifer");
            }

            var sproc = new GoodsSaveItemImage()
            {
                Delete         = image.Delete,
                IsPrimary      = image.IsPrimary,
                UserIdentifier = userId,
                Identifier     = image.Identifier,
            };

            return(sproc.CallObject <ItemImage>());
        }
Beispiel #2
0
        /// <summary>
        /// Save Image
        /// </summary>
        /// <param name="image">Image</param>
        /// <returns>Item Image</returns>
        public ItemImage Save(ItemImageInput image)
        {
            var id          = Guid.NewGuid();
            var virtualPath = string.Format("item/{0}_{1}.jpg", id, "{0}");
            var sproc       = new GoodsSaveItemImage()
            {
                Identifier     = id,
                ContentType    = image.ContentType,
                FileName       = image.FileName,
                FileSize       = image.FileSize,
                ItemIdentifier = image.ItemIdentifier,
                UserIdentifier = image.UserIdentifier,
                Path           = string.Format("/user/{0}", virtualPath),
            };

            var storedImage = sproc.CallObject <ItemImageInput>();

            var container = new BinaryContainer("user");

            container.Save(string.Format(virtualPath, OriginalName), image.Contents, image.ContentType);

            var thumbnail = this.Thumbnail(image.Contents, ImageFormat.Jpeg);

            var thumbnailPath = string.Format(virtualPath, ImageCore.ThumbnailName);

            container.Save(thumbnailPath, thumbnail, contentType);

            var large = this.Large(image.Contents, ImageFormat.Jpeg);

            var largePath = string.Format(virtualPath, ImageCore.LargeName);

            container.Save(largePath, large, contentType);

            var activity = new ActivityCore();

            activity.NewItemImage(storedImage);

            return(new ItemImage()
            {
                VirtualPathFormat = string.Format("/user/{0}", thumbnailPath),
            });
        }