Example #1
0
		/// <summary>
		/// Gets the album from the data transfer object. Guaranteed to not return null.
		/// </summary>
		/// <param name="albumDto">The album data transfer object.</param>
		/// <returns>Returns an <see cref="IAlbum" />.</returns>
		/// <exception cref="InvalidAlbumException">Thrown when <paramref name="albumDto" /> is null.</exception>
		public static IAlbum GetAlbumFromDto(AlbumDto albumDto)
		{
			if (albumDto == null)
			{
				throw new InvalidAlbumException();
			}

			IAlbum album = new Album(albumDto.AlbumId,
															 albumDto.FKGalleryId,
															 albumDto.FKAlbumParentId.GetValueOrDefault(0),
															 albumDto.DirectoryName,
															 albumDto.ThumbnailMediaObjectId,
															 albumDto.SortByMetaName,
															 albumDto.SortAscending,
															 albumDto.Seq,
															 HelperFunctions.ToDateTime(albumDto.DateStart),
															 HelperFunctions.ToDateTime(albumDto.DateEnd),
															 albumDto.CreatedBy.Trim(),
															 HelperFunctions.ToDateTime(albumDto.DateAdded),
															 albumDto.LastModifiedBy.Trim(),
															 HelperFunctions.ToDateTime(albumDto.DateLastModified),
															 albumDto.OwnedBy.Trim(),
															 albumDto.OwnerRoleName.Trim(),
															 albumDto.IsPrivate,
															 true,
															 albumDto.Metadata);

			//ToGalleryObjectMetadataItemCollection(album, albumDto.Metadata);
			//album.IsInflated = true;
			// Since we've just loaded this object from the data store, set the corresponding property.
			album.FullPhysicalPathOnDisk = album.FullPhysicalPath;

			return album;
		}
Example #2
0
            /// <summary>
            /// Gets the album from the data transfer object. Guaranteed to not return null.
            /// </summary>
            /// <param name="albumDto">The album data transfer object.</param>
            /// <returns>Returns an <see cref="IAlbum" />.</returns>
            /// <exception cref="InvalidAlbumException">Thrown when <paramref name="albumDto" /> is null.</exception>
            private static IAlbum GetAlbumFromDto(AlbumDto albumDto)
            {
            if (albumDto == null)
            {
                throw new InvalidAlbumException();
            }

            IAlbum album = null;
            try
            {
                album = new Album(albumDto.AlbumId,
                                                    albumDto.FKGalleryId,
                                                    albumDto.AlbumParentId,
                                                    albumDto.Title,
                                                    albumDto.DirectoryName,
                                                    albumDto.Summary,
                                                    albumDto.ThumbnailMediaObjectId,
                                                    albumDto.Seq,
                                                    HelperFunctions.ToDateTime(albumDto.DateStart),
                                                    HelperFunctions.ToDateTime(albumDto.DateEnd),
                                                    albumDto.CreatedBy.Trim(),
                                                    HelperFunctions.ToDateTime(albumDto.DateAdded),
                                                    albumDto.LastModifiedBy.Trim(),
                                                    HelperFunctions.ToDateTime(albumDto.DateLastModified),
                                                    albumDto.OwnedBy.Trim(),
                                                    albumDto.OwnerRoleName.Trim(),
                                                    albumDto.IsPrivate);

                album.IsInflated = true;
            }
            catch
            {
                if (album != null)
                    album.Dispose();

                throw;
            }

            return album;
            }
Example #3
0
		private static IAlbum GetAlbumFromDataReader(IDataReader dr)
		{
			// SQL:
			// SELECT
			// AlbumID, FKGalleryID as GalleryID, AlbumParentID, Title, DirectoryName, Summary, ThumbnailMediaObjectID, 
			//  Seq, DateStart, DateEnd, CreatedBy, DateAdded, LastModifiedBy, DateLastModified, OwnedBy, OwnerRoleName, IsPrivate
			// FROM [gs_Album]
			// WHERE AlbumId = @AlbumId AND FKGalleryId = @GalleryId
			IAlbum album = null;
			while (dr.Read())
			{
				// A parent ID = 0 indicates the root album. Use int.MinValue to send to Album constructor.
				//int albumParentId = (Int32.Parse(dr["AlbumParentID"].ToString(), CultureInfo.InvariantCulture) == 0 ? int.MinValue : Int32.Parse(dr["AlbumParentID"].ToString(), CultureInfo.InvariantCulture));
				int albumParentId = Int32.Parse(dr["AlbumParentID"].ToString(), CultureInfo.InvariantCulture);

				album = new Album(Int32.Parse(dr["AlbumID"].ToString(), CultureInfo.InvariantCulture),
				                  albumParentId,
				                  dr["Title"].ToString(),
				                  dr["DirectoryName"].ToString(),
				                  dr["Summary"].ToString(),
				                  Int32.Parse(dr["ThumbnailMediaObjectID"].ToString(), CultureInfo.InvariantCulture),
				                  Int32.Parse(dr["Seq"].ToString(), CultureInfo.InvariantCulture),
				                  HelperFunctions.ToDateTime((dr["DateStart"])),
				                  HelperFunctions.ToDateTime(dr["DateEnd"]),
				                  dr["CreatedBy"].ToString().Trim(),
				                  HelperFunctions.ToDateTime(dr["DateAdded"]),
				                  dr["LastModifiedBy"].ToString().Trim(),
				                  HelperFunctions.ToDateTime(dr["DateLastModified"]),
				                  dr["OwnedBy"].ToString().Trim(),
				                  dr["OwnerRoleName"].ToString().Trim(),
				                  Convert.ToBoolean(dr["IsPrivate"].ToString(), CultureInfo.InvariantCulture));
			}

			if (album == null)
			{
				throw new InvalidAlbumException();
			}

			album.IsInflated = true;

			return album;
		}