public HttpResponseMessage SaveImage()
        {
            if (!Request.Content.IsMimeMultipartContent())
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            var httpRequest = HttpContext.Current.Request;

            if (httpRequest.Files.Count == 0)
            {
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
            }

            ImageInformation normalImageInformation = new ImageInformation
            {
                Width             = AppSettingsUtils.GetDimensionWidth("PromotionProductImagesNormalDimension"),
                Height            = AppSettingsUtils.GetDimensionHeight("PromotionProductImagesNormalDimension"),
                BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("PromotionProductBlobImagesTempDirectory")
            };

            string fileName = UploadFileHandler.SaveUploadedImage(httpRequest.Files[0], normalImageInformation);

            return(Request.CreateResponse <ImageModel>(HttpStatusCode.OK, new ImageModel {
                ImageFileNamePath = normalImageInformation.RelativeFileName, ImageFileName = fileName
            }));
        }
        private void ResizeLogos(PromotionProductDto promotionProductDto)
        {
            string logoFileName = System.IO.Path.Combine(AppSettingsUtils.GetStringAppSetting("PromotionProductBlobImagesTempDirectory"), promotionProductDto.Logo);

            UploadFileHandler.ResizeFromStreamImage(logoFileName, promotionProductDto.Logo,
                                                    new ImageInformation
            {
                Width             = AppSettingsUtils.GetDimensionWidth("PromotionProductImagesNormalDimension"),
                Height            = AppSettingsUtils.GetDimensionHeight("PromotionProductImagesNormalDimension"),
                BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("PromotionProductBlobImagesNormalDirectory")
            });

            UploadFileHandler.ResizeFromStreamImage(logoFileName, promotionProductDto.Logo,
                                                    new ImageInformation
            {
                Width             = AppSettingsUtils.GetDimensionWidth("PromotionProductImagesThumbnailsDimension"),
                Height            = AppSettingsUtils.GetDimensionHeight("PromotionProductImagesThumbnailsDimension"),
                BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("PromotionProductBlobImagesThumbnailsDirectory")
            });

            UploadFileHandler.ResizeFromStreamImage(logoFileName, promotionProductDto.Logo,
                                                    new ImageInformation
            {
                Width             = AppSettingsUtils.GetDimensionWidth("PromotionProductImagesPreviewDimension"),
                Height            = AppSettingsUtils.GetDimensionHeight("PromotionProductImagesPreviewDimension"),
                BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("PromotionProductBlobImagesPreviewDirectory")
            });
        }
Ejemplo n.º 3
0
        private void MapRelativeLogoPath(ProductDto productDto)
        {
            if (string.IsNullOrEmpty(productDto.Logo))
            {
                return;
            }

            productDto.RelativeFileName = UploadFileHandler.GetBlobRelativeFileName(AppSettingsUtils.GetStringAppSetting("StoragePrefixUrl"), AppSettingsUtils.GetStringAppSetting("ProductImagesBlobThumbnailsDirectory"), productDto.Logo);
        }
Ejemplo n.º 4
0
        private void ResizeLogo(CompanyLogoDto companyLogo, bool isLogo)
        {
            string logoFileName = System.IO.Path.Combine(AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobTempDirectory"), companyLogo.Logo);

            if (isLogo)
            {
                UploadFileHandler.ResizeFromStreamImage(logoFileName, companyLogo.Logo,
                                                        new ImageInformation
                {
                    Width             = AppSettingsUtils.GetDimensionWidth("CompanyImagesLogoDimension"),
                    Height            = AppSettingsUtils.GetDimensionHeight("CompanyImagesLogoDimension"),
                    BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobLogoDirectory")
                });

                return;
            }

            UploadFileHandler.ResizeFromStreamImage(logoFileName, companyLogo.Logo,
                                                    new ImageInformation
            {
                Width             = AppSettingsUtils.GetDimensionWidth("CompanyImagesNormalDimension"),
                Height            = AppSettingsUtils.GetDimensionHeight("CompanyImagesNormalDimension"),
                BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobNormalDirectory")
            });

            UploadFileHandler.ResizeFromStreamImage(logoFileName, companyLogo.Logo,
                                                    new ImageInformation
            {
                Width             = AppSettingsUtils.GetDimensionWidth("CompanyImagesThumbnailsDimension"),
                Height            = AppSettingsUtils.GetDimensionHeight("CompanyImagesThumbnailsDimension"),
                BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobThumbnailsDirectory")
            });

            UploadFileHandler.ResizeFromStreamImage(logoFileName, companyLogo.Logo,
                                                    new ImageInformation
            {
                Width             = AppSettingsUtils.GetDimensionWidth("CompanyImagesPreviewDimension"),
                Height            = AppSettingsUtils.GetDimensionHeight("CompanyImagesPreviewDimension"),
                BlobDirectoryName = AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobPreviewDirectory")
            });
        }
Ejemplo n.º 5
0
        private void MapRelativeLogoPath(CompanyDto companyDto)
        {
            if (companyDto.Galleries == null || companyDto.Galleries.Count == 0 || companyDto.Logo == null)
            {
                return;
            }

            if (companyDto.Logo != null && !string.IsNullOrEmpty(companyDto.Logo.Logo))
            {
                companyDto.Logo.NormalRelativeFileName = UploadFileHandler.GetBlobRelativeFileName(AppSettingsUtils.GetStringAppSetting("StoragePrefixUrl"), AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobLogoDirectory"), companyDto.Logo.Logo);
            }

            foreach (var companyLogo in companyDto.Galleries)
            {
                if (string.IsNullOrEmpty(companyLogo.Logo))
                {
                    return;
                }

                companyLogo.NormalRelativeFileName    = UploadFileHandler.GetBlobRelativeFileName(AppSettingsUtils.GetStringAppSetting("StoragePrefixUrl"), AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobNormalDirectory"), companyLogo.Logo);
                companyLogo.ThumbnailRelativeFileName = UploadFileHandler.GetBlobRelativeFileName(AppSettingsUtils.GetStringAppSetting("StoragePrefixUrl"), AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobThumbnailsDirectory"), companyLogo.Logo);
                companyLogo.PreviewRelativeFileName   = UploadFileHandler.GetBlobRelativeFileName(AppSettingsUtils.GetStringAppSetting("StoragePrefixUrl"), AppSettingsUtils.GetStringAppSetting("CompanyImagesBlobPreviewDirectory"), companyLogo.Logo);
            }
        }