/// <summary> /// Updates the data store records with the values of this instance. /// </summary> private void SaveExisting() { if (MimeTypeId == int.MinValue) { throw new InvalidOperationException("Cannot call SaveExisting for new MIME types."); } using (var repo = new MimeTypeRepository()) { var mtDto = repo.Find(MimeTypeId); if (mtDto != null && mtDto.MimeTypeValue != FullType) { mtDto.MimeTypeValue = FullType; repo.Save(); } } using (var repo = new MimeTypeGalleryRepository()) { var mtDto = repo.Find(MimeTypeGalleryId); if (mtDto != null && mtDto.IsEnabled != AllowAddToGallery) { mtDto.IsEnabled = AllowAddToGallery; repo.Save(); } } }
/// <summary> /// Permanently delete this MIME type from the data store. /// </summary> public void Delete() { if (MimeTypeId == int.MinValue) { return; } using (var repo = new MimeTypeRepository()) { var mtDto = repo.Find(MimeTypeId); if (mtDto != null) { repo.Delete(mtDto); repo.Save(); } } }