Ejemplo n.º 1
0
		private static void InflateAlbumFromDto(IAlbum album, AlbumDto albumDto)
		{
			if (album == null)
				throw new ArgumentNullException("album");

			if (albumDto == null)
				throw new ArgumentNullException("albumDto");

			// A parent ID = null indicates the root album. Use int.MinValue to send to Album constructor.
			int albumParentId = albumDto.FKAlbumParentId.GetValueOrDefault(Int32.MinValue);

			// Assign parent if it hasn't already been assigned.
			if ((album.Parent.Id == Int32.MinValue) && (albumParentId > Int32.MinValue))
			{
				album.Parent = CreateAlbumInstance(albumParentId, albumDto.FKGalleryId);
			}

			album.GalleryId = albumDto.FKGalleryId;
			//album.Title = albumDto.Title;
			album.DirectoryName = albumDto.DirectoryName;
			//album.Summary = albumDto.Summary;
			album.SortByMetaName = albumDto.SortByMetaName;
			album.SortAscending = albumDto.SortAscending;
			album.Sequence = albumDto.Seq;
			album.DateStart = HelperFunctions.ToDateTime(albumDto.DateStart);
			album.DateEnd = HelperFunctions.ToDateTime(albumDto.DateEnd);
			album.CreatedByUserName = albumDto.CreatedBy.Trim();
			album.DateAdded = HelperFunctions.ToDateTime(albumDto.DateAdded);
			album.LastModifiedByUserName = albumDto.LastModifiedBy.Trim();
			album.DateLastModified = HelperFunctions.ToDateTime(albumDto.DateLastModified);
			album.OwnerUserName = albumDto.OwnedBy.Trim();
			album.OwnerRoleName = albumDto.OwnerRoleName.Trim();
			album.IsPrivate = albumDto.IsPrivate;

			// Set the album's thumbnail media object ID. Setting this property sets an internal flag that will cause
			// the media object info to be retrieved when the Thumbnail property is accessed. That's why we don't
			// need to set any of the thumbnail properties.
			// WARNING: No matter what, do not call DisplayObject.CreateInstance() because that creates a new object, 
			// and we might be  executing this method from within our Thumbnail display object. Trust me, this 
			// creates hard to find bugs!
			album.ThumbnailMediaObjectId = albumDto.ThumbnailMediaObjectId;

			album.AddMeta(GalleryObjectMetadataItemCollection.FromMetaDtos(album, albumDto.Metadata));
		}