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")
            });
        }
        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
            }));
        }
Ejemplo n.º 3
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")
            });
        }