Esempio n. 1
0
        FileReference IEmployerLogosCommand.SaveLogo(FileContents fileContents, string fileName)
        {
            var extension = Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }
            extension = extension.TrimStart('.');
            if (!_imagesCommand.IsValidFileExtension(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }

            // Save it after cropping it to an appropriate size.

            using (var stream = _imagesCommand.Crop(fileContents.GetStream(), Roles.JobAds.Constants.LogoMaxSize, _imagesCommand.GetFormat(extension)))
            {
                return(_filesCommand.SaveFile(FileType.CompanyLogo, new StreamFileContents(stream), fileName));
            }
        }
Esempio n. 2
0
        FileReference IMemberPhotosCommand.SavePhoto(FileContents fileContents, string fileName)
        {
            var extension = Path.GetExtension(fileName);

            if (string.IsNullOrEmpty(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }
            extension = extension.TrimStart('.');
            if (!_imagesCommand.IsValidFileExtension(extension))
            {
                throw new InvalidImageExtensionException(extension);
            }
            fileName = Path.ChangeExtension(fileName, StorageExtension);

            // Save it after converting it to an appropriate size and format.

            using (var stream = _imagesCommand.Resize(fileContents.GetStream(), Domain.Contacts.Constants.PhotoMaxSize, StorageFormat))
            {
                return(_filesCommand.SaveFile(FileType.ProfilePhoto, new StreamFileContents(stream), fileName));
            }
        }