/// <summary> /// Persist this gallery object to the data store. /// </summary> public void Save() { bool isNew = IsNew; using (var repo = new GalleryRepository()) { if (IsNew) { var galleryDto = new GalleryDto { Description = Description, DateAdded = CreationDate }; repo.Add(galleryDto); repo.Save(); _id = galleryDto.GalleryId; } else { var galleryDto = repo.Find(GalleryId); if (galleryDto != null) { galleryDto.Description = Description; repo.Save(); } else { throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId)); } } } // For new galleries, configure it and then trigger the created event. if (isNew) { Configure(); EventHandler <GalleryCreatedEventArgs> galleryCreated = GalleryCreated; if (galleryCreated != null) { galleryCreated(null, new GalleryCreatedEventArgs(GalleryId)); } } Factory.ClearAllCaches(); }
/// <summary> /// Persist this gallery instance to the data store. /// </summary> public void Save() { bool isNew = IsNew; using (var repo = new GalleryRepository()) { if (IsNew) { var galleryDto = new GalleryDto { Description = Description, DateAdded = CreationDate }; repo.Add(galleryDto); repo.Save(); _id = galleryDto.GalleryId; } else { var galleryDto = repo.Find(GalleryId); if (galleryDto != null) { galleryDto.Description = Description; repo.Save(); } else { throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId)); } } } // For new galleries, configure it and then trigger the created event. if (isNew) { Validate(); Factory.ClearGalleryCache(); // Needed so LoadGalleries(), called by AddDefaultRolesToRoleAlbumTable(), pulls new gallery from data store AddDefaultRolesToRoleAlbumTable(); } Factory.ClearAllCaches(); }
/// <summary> /// Persist this gallery object to the data store. /// </summary> public void Save() { bool isNew = IsNew; using (var repo = new GalleryRepository()) { if (IsNew) { var galleryDto = new GalleryDto { Description = Description, DateAdded = CreationDate }; repo.Add(galleryDto); repo.Save(); _id = galleryDto.GalleryId; } else { var galleryDto = repo.Find(GalleryId); if (galleryDto != null) { galleryDto.Description = Description; repo.Save(); } else { throw new BusinessException(String.Format(CultureInfo.CurrentCulture, "Cannot save gallery: No existing gallery with Gallery ID {0} was found in the database.", GalleryId)); } } } // For new galleries, configure it and then trigger the created event. if (isNew) { Configure(); EventHandler<GalleryCreatedEventArgs> galleryCreated = GalleryCreated; if (galleryCreated != null) { galleryCreated(null, new GalleryCreatedEventArgs(GalleryId)); } } Factory.ClearAllCaches(); }