public static void DeleteFileByMetadata(FileMetadata metadata, CerebelloEntitiesAccessFilterWrapper db, IBlobStorageManager storage) { // deleting dependent files var relatedFiles = db.FileMetadatas.Where(f => f.RelatedFileMetadataId == metadata.Id).ToList(); foreach (var relatedFile in relatedFiles) { DeleteFileByMetadata(relatedFile, db, storage); } // deleting file metadata and storage entries storage.DeleteFileFromStorage(metadata.ContainerName, metadata.BlobName); db.FileMetadatas.DeleteObject(metadata); }
/// <summary> /// Deletes a file from the Window Azure Storage. /// </summary> /// <param name="this">Blob storage manager to use.</param> /// <param name="location">Location of the blob to delete.</param> public static void DeleteFileFromStorage(this IBlobStorageManager @this, BlobLocation location) { @this.DeleteFileFromStorage(location.ContainerName, location.BlobName); }