Exemplo n.º 1
0
        private bool SaveImages(Category c)
        {
            var result = true;

            // Icon Image Upload
            if (ucIconImage.HasFile)
            {
                var fileName = Text.CleanFileName(Path.GetFileName(ucIconImage.FileName));

                if (DiskStorage.CopyCategoryIcon(HccApp.CurrentStore.Id, c.Bvin, ucIconImage.TempImagePath, fileName))
                {
                    c.ImageUrl = fileName;
                }
                else
                {
                    result = false;
                    ucMessageBox.ShowError("Only .PNG, .JPG, .GIF file types are allowed for icon images");
                }
            }
            else if (ucIconImage.Removed)
            {
                c.ImageUrl = string.Empty;
            }

            // Banner Image Upload
            if (ucBannerImage.HasFile)
            {
                var fileName = Text.CleanFileName(Path.GetFileName(ucBannerImage.FileName));

                if (DiskStorage.CopyCategoryBanner(HccApp.CurrentStore.Id, c.Bvin, ucBannerImage.TempImagePath, fileName))
                {
                    c.BannerImageUrl = fileName;
                }
                else
                {
                    result = false;
                    ucMessageBox.ShowError("Only .PNG, .JPG, .GIF file types are allowed for banner images");
                }
            }
            else if (ucBannerImage.Removed)
            {
                c.BannerImageUrl = string.Empty;
            }

            return(result);
        }
Exemplo n.º 2
0
        private bool SaveImages(Category c)
        {
            var result = true;

            // Icon Image Upload
            if (ucIconImage.HasFile)
            {
                var fileName = Text.CleanFileName(Path.GetFileName(ucIconImage.FileName));

                if (DiskStorage.CopyCategoryIcon(HccApp.CurrentStore.Id, c.Bvin, ucIconImage.TempImagePath, fileName))
                {
                    c.ImageUrl = fileName;
                }
                else
                {
                    result = false;
                    ucMessageBox.ShowError(Localization.GetString("ImageSaveFailure"));
                }
            }
            else if (ucIconImage.Removed)
            {
                c.ImageUrl = string.Empty;
            }

            // Banner Image Upload
            if (ucBannerImage.HasFile)
            {
                var fileName = Text.CleanFileName(Path.GetFileName(ucBannerImage.FileName));

                if (DiskStorage.CopyCategoryBanner(HccApp.CurrentStore.Id, c.Bvin, ucBannerImage.TempImagePath, fileName))
                {
                    c.BannerImageUrl = fileName;
                }
                else
                {
                    result = false;
                    ucMessageBox.ShowError(Localization.GetString("ImageSaveFailure"));
                }
            }
            else if (ucBannerImage.Removed)
            {
                c.BannerImageUrl = string.Empty;
            }

            return(result);
        }