/// <summary> /// Adds a copy of the lightbox asset to the lightbox, if it does not contain the asset /// </summary> public void AddAssetToLightbox(Lightbox lightbox, LightboxAsset lightboxAsset) { if (!lightbox.IsNull && !lightboxAsset.IsNull) { if (EntitySecurityManager.CanManageLightbox(User, lightbox)) { if (!LightboxContainsAsset(lightbox, lightboxAsset.AssetId)) { LightboxAsset lba = LightboxAsset.New(); lba.LightboxId = lightbox.LightboxId.GetValueOrDefault(); lba.AssetId = lightboxAsset.AssetId; lba.Notes = lightboxAsset.Notes; lba.CreateDate = DateTime.Now; LightboxAsset.Update(lba); AuditLogManager.LogAssetAction(lightboxAsset.AssetId, User, AuditAssetAction.AddedToLightbox); AuditLogManager.LogUserAction(User, AuditUserAction.AddToLightbox, string.Format("Added AssetId: {0} to LightboxId: {1}", lightboxAsset.AssetId, lightbox.LightboxId.GetValueOrDefault())); } } else { m_Logger.DebugFormat("User: {0} (UserId: {1}) tried to add AssetId: {2} to LightboxId: {3} but couldn't due to insufficient permissions to manage ths lightbox", User.FullName, User.UserId, lightboxAsset.AssetId, lightbox.LightboxId.GetValueOrDefault()); } } }
/// <summary> /// creates a new lightbox asset and adds this to the lightbox with the specified ID, if it does not contain it already /// </summary> public void AddAssetToLightbox(int lightboxId, int assetId) { LightboxAsset lba = LightboxAsset.New(); lba.LightboxId = lightboxId; lba.AssetId = assetId; AddAssetToLightbox(lightboxId, lba); }
private Lightbox DuplicateLightbox(int lightboxId, string newName, int targetUserId) { ValidateLightboxName(newName); if (IsDuplicateName(newName, targetUserId)) { string message = (targetUserId == User.UserId.GetValueOrDefault()) ? "A lightbox with that name already exists" : "User already has a lightbox with that name"; throw new InvalidLightboxException(message); } Lightbox lightbox = GetLightboxById(lightboxId); Lightbox newLightbox = Lightbox.New(); newLightbox.UserId = targetUserId; newLightbox.Name = newName; newLightbox.Summary = lightbox.Summary; newLightbox.Notes = lightbox.Notes; newLightbox.IsDefault = false; newLightbox.CreateDate = DateTime.Now; SaveLightbox(newLightbox); foreach (LightboxAsset lba in lightbox.GetLightboxAssetList()) { LightboxAsset newlba = LightboxAsset.New(); newlba.LightboxId = newLightbox.LightboxId.GetValueOrDefault(); newlba.AssetId = lba.AssetId; newlba.Notes = lba.Notes; newlba.CreateDate = DateTime.Now; LightboxAsset.Update(newlba); } return(newLightbox); }