public async Task <IActionResult> DeletePhotos([Bind("_id", "ToBeDelete")] List <PhotoModelForDelete> photos) { List <string> blobsReferenceName = new List <string>(); using ( MyBlobStorageManager myBlobStorageManager = new MyBlobStorageManager(Variables.BlobStorageConnectionString, _userId)) { foreach (var photo in photos) { if (photo.ToBeDelete) { var photosName = await _myMongoDbManager.GetPhotosNameAsync(new ObjectId(photo._id)); blobsReferenceName.AddRange(photosName); _myMongoDbManager.RemovePhotoAsync(new ObjectId(photo._id)); } } foreach (var name in blobsReferenceName) { await myBlobStorageManager.RemoveDocumentByNameAsync(name); } } return(RedirectToAction("Gallery", "Gallery")); }