Esempio n. 1
0
        public static string BlobFullUrl(this EditionImageType editionImageType, EditionTranslationEntity editionTranslation)
        {
            var fileName = editionTranslation.GetFileName(editionImageType);

            if (string.IsNullOrWhiteSpace(fileName))
            {
                return(editionImageType.EditionDefaultImageUrl());
            }
            return(editionImageType.BlobSubDirectory() + fileName);
        }
        public static void CopyEditionImages(int editionId, string editionName, EditionTranslationEntity sourceEditionTranslation, EditionTranslationEntity targetEditionTranslation)
        {
            foreach (EditionImageType imageType in Enum.GetValues(typeof(EditionImageType)))
            {
                var sourceFileName = sourceEditionTranslation.GetFileName(imageType);
                var targetFileName = ComposeImageName(editionId, editionName, targetEditionTranslation.LanguageCode, Path.GetExtension(sourceFileName));

                var uploadedFileName = CopyImageOnAzure(sourceFileName, targetFileName, imageType);

                targetEditionTranslation.SetFileName(imageType, uploadedFileName);
            }
        }
        public static void RenameEditionImages(int editionId, string newEditionName, EditionTranslationEntity editionTranslation)
        {
            var azureService = new Service();

            foreach (EditionImageType imageType in Enum.GetValues(typeof(EditionImageType)))
            {
                var oldFileName = editionTranslation.GetFileName(imageType);
                var newFileName = ComposeImageName(editionId, newEditionName, editionTranslation.LanguageCode, Path.GetExtension(oldFileName));

                var oldFileFullName = imageType.BlobFullName(oldFileName);
                var newFileFullName = imageType.BlobFullName(newFileName);

                azureService.RenameFile(oldFileFullName, newFileFullName);

                editionTranslation.SetFileName(imageType, newFileName);
            }
        }