Ejemplo n.º 1
0
        public WebImage GetAlbumPhoto(int year, string slug, int photoIndex, AlbumPhotoType albumPhotoType)
        {
            Album album = GetAlbum(year, slug);

            if (album == null)
            {
                return null;
            }

            int maxDimension;

            string resizedFilePath;

            string photoFilePath = GetValidPhotoFilePaths(album.DirectoryPath).ElementAt(photoIndex);

            switch (albumPhotoType)
            {
                case AlbumPhotoType.Thumbnail:
                    maxDimension = MaxThumbnailDimension;
                    resizedFilePath = GetAlbumPhotoThumbnailFilePath(album.DirectoryPath, photoFilePath);
                    break;
                case AlbumPhotoType.WebOptimized:
                    maxDimension = MaxWebOptimizedDimension;
                    resizedFilePath = GetAlbumPhotoWebOptimizedFilePath(album.DirectoryPath, photoFilePath);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("albumPhotoType");
            }

            EnsureImageExists(maxDimension, photoFilePath, resizedFilePath);

            return new WebImage
                       {
                           FilePath = resizedFilePath
                       };
        }