/// <summary> /// Creates a deep copy of this instance. /// </summary> /// <returns>Returns a deep copy of this instance.</returns> public IGallery Copy() { IGallery galleryCopy = new Gallery(); galleryCopy.GalleryId = this.GalleryId; galleryCopy.Description = this.Description; galleryCopy.CreationDate = this.CreationDate; galleryCopy.Albums = new Dictionary<int, List<int>>(this.Albums.Count); foreach (KeyValuePair<int, List<int>> kvp in this.Albums) { galleryCopy.Albums.Add(kvp.Key, new List<int>(kvp.Value)); } return galleryCopy; }
/// <summary> /// Permanently delete the profile records associated with the specified <paramref name="gallery" />. /// </summary> /// <param name="gallery">The gallery.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="gallery" /> is null.</exception> public static void DeleteProfileForGallery(Gallery gallery) { if (gallery == null) throw new ArgumentNullException("gallery"); using (var repo = new ProfileRepository()) { foreach (var pDto in repo.Where(p => p.FKGalleryId == gallery.GalleryId)) { repo.Delete(pDto); } repo.Save(); } }