public async Task Delete() { var data1 = new TestEntity(1, "hello 1", "p1", "r1"); var data2 = new TestEntity(2, "hello 2", "p2", "r2"); await Storage.InsertAsync(data1); await Storage.InsertAsync(data2); var deleted = await Storage.DeleteAsync("p2", "r2"); Assert.IsTrue(Equals(deleted, data2), "not equals deleted and data2"); Assert.AreEqual(1, Storage.Count()); await Storage.InsertAsync(data2); Assert.AreEqual(2, Storage.Count()); await Storage.DeleteAsync(data1); Assert.AreEqual(1, Storage.Count()); Assert.IsTrue(Equals(data2, await Storage.GetDataAsync("p2", "r2")), "not equals after delete by entity"); await Storage.InsertAsync(data1); await Storage.DeleteIfExistAsync("p1", "r1"); await Storage.DeleteIfExistAsync("p1", "r1"); Assert.AreEqual(1, Storage.Count()); Assert.IsTrue(Equals(data2, await Storage.GetDataAsync("p2", "r2")), "not equals after delete by entity"); }
public async Task Complete(string requestId) { var record = await _table.DeleteAsync(OffchainRequestEntity.ByRecord.Partition, requestId); await _table.DeleteAsync(OffchainRequestEntity.ByClient.GeneratePartition(record.ClientId), requestId); await _table.InsertOrReplaceAsync(OffchainRequestEntity.Archieved.Create(record)); }
public async Task DeleteSessionAsync(string clientId, string token) { var partitionKey = ClientSessionEntity.ByToken.GeneratePartitionKey(); var rowKey = ClientSessionEntity.ByToken.GenerateRowKey(token); await _tableStorage.DeleteAsync(partitionKey, rowKey); partitionKey = ClientSessionEntity.ByClient.GeneratePartitionKey(clientId); rowKey = ClientSessionEntity.ByClient.GenerateRowKey(token); await _tableStorage.DeleteAsync(partitionKey, rowKey); }
public async Task DeleteAsync(string to, string campaignId = null) { var emails = string.IsNullOrEmpty(campaignId) ? await _tableStorage.GetDataAsync(GetPartitionKey(to)) : await _tableStorage.GetDataAsync(GetPartitionKey(to), email => email.CampaignId == campaignId); if (emails.Any()) { await _tableStorage.DeleteAsync(emails); } }
public async Task DeleteKeyValueWithHistoryAsync(string keyValueId, string description, string userName, string userIpAddress) { var kvItem = await _tableStorage.GetDataAsync(KeyValueEntity.GeneratePartitionKey(), keyValueId); if (kvItem != null) { await _tableStorage.DeleteAsync(kvItem); await _history.DeleteKeyValueHistoryAsync(keyValueId, description, userName, userIpAddress); } }
public async Task DeleteAsync(string projectId, string participantId, string voterId) { var partitionKey = ProjectResultVoteEntity.GeneratePartitionKey(projectId); var rowKey = ProjectResultVoteEntity.GenerateRowKey(participantId, voterId); await _projectResultVoteTableStorage.DeleteAsync(partitionKey, rowKey); }
public async Task DeleteAsync(string clientId, string disclaimerId) { await _storage.DeleteAsync(GetPartitionKey(clientId), GetRowKey(disclaimerId)); await _disclaimerIdIndexStorage .DeleteAsync(GetDisclaimerIdIndexPartitionKey(disclaimerId), GetDisclaimerIdIndexRowKey(clientId)); }
public Task DeleteAsync(string transactionId) { var partitionKey = BitCoinTransactionEntity.ByTransactionId.GeneratePartitionKey(); var rowKey = BitCoinTransactionEntity.ByTransactionId.GenerateRowKey(transactionId); return(_tableStorage.DeleteAsync(partitionKey, rowKey)); }
public async Task <ICustomerChecksInfo> DeleteAsync(string clientId) { var partitionKey = CustomerChecksInfoEntity.GeneratePartitionKey(clientId); var rowKey = CustomerChecksInfoEntity.GenerateRowKey(clientId); return(await _tableStorage.DeleteAsync(partitionKey, rowKey)); }
private async Task UpdateIndexes(InventorySnapshotEntity inventorySnapshotEntity) { var existingIndex = await _indexStorage.GetDataAsync(GetIndexPartitionKey(inventorySnapshotEntity.Time), IndexForLastRowKey); if (existingIndex == null || (await _storage.GetDataAsync(existingIndex)).Time < inventorySnapshotEntity.Time) { // Update index for current day, it now must point to this the last received snapshot await _indexStorage.InsertOrReplaceAsync( AzureIndex.Create(GetIndexPartitionKey(inventorySnapshotEntity.Time), IndexForLastRowKey, inventorySnapshotEntity)); } // If we have index entries for any future date, they are now are invalid, we can just remove them, // as they will be reconstructed if needed var filter = TableQuery.GenerateFilterCondition(nameof(AzureIndex.PartitionKey), QueryComparisons.GreaterThan, GetIndexPartitionKey(inventorySnapshotEntity.Time)); var query = new TableQuery <AzureIndex>().Where(filter); var allNowInvalidIndexEntriesFromTheFuture = (await _indexStorage.WhereAsync(query)).ToList(); foreach (var indexEntity in allNowInvalidIndexEntriesFromTheFuture) { await _indexStorage.DeleteAsync(indexEntity); } }
public async Task DeleteAsync(string id) { var partitionKey = ProjectEntity.GeneratePartitionKey(); var rowKey = ProjectEntity.GenerateRowKey(id); await _projectsTableStorage.DeleteAsync(partitionKey, rowKey); }
public async Task UpdateOrderAsync(OrderBase updatedOrder) { var partitionKey = OrderEntity.GeneratePartitionKey(updatedOrder.TraderId); var rowKey = OrderEntity.GenerateRowKey(updatedOrder.Id); var oldStatus = OrderStatus.Registered; await _tableStorage.ReplaceAsync(partitionKey, rowKey, itm => { oldStatus = itm.GetOrder().Status; itm.SetOrder(updatedOrder); return(itm); }); if (oldStatus == updatedOrder.Status) { await _tableStorage.ReplaceAsync(OrderEntity.GeneratePartitionAsAllOrders(oldStatus), rowKey, itm => { itm.SetOrder(updatedOrder); return(itm); }); return; } partitionKey = OrderEntity.GeneratePartitionAsAllOrders(oldStatus); await _tableStorage.DeleteAsync(partitionKey, rowKey); var newEntity = OrderEntity.Create(updatedOrder); await _tableStorage.InsertOrReplaceAsync(newEntity); }
public async Task DeleteAsync(string invoiceId) { IEnumerable <PaymentRequestHistoryItemEntity> entities = await _storage.GetDataAsync(GetPartitionKey(invoiceId)); await _storage.DeleteAsync(entities); }
public async Task DeleteAsync(string projectId, string commentId) { var partitionKey = CommentEntity.GeneratePartitionKey(projectId); var rowKey = CommentEntity.GenerateRowKey(commentId); await _projectCommentsTableStorage.DeleteAsync(partitionKey, rowKey); }
public async Task DeleteAsync(string projectId, string userId) { var partitionKey = WinnerEntity.GeneratePartitionKey(projectId); var rowKey = WinnerEntity.GenerateRowKey(userId); await _winnersStorage.DeleteAsync(partitionKey, rowKey); }
public async Task <IGlobalCheckInfo> DeleteAsync(DateTime timestamp) { var partitionKey = GlobalCheckInfoEntity.GeneratePartitionKey(timestamp); var rowKey = GlobalCheckInfoEntity.GenerateRowKey(timestamp); return(await _tableStorage.DeleteAsync(partitionKey, rowKey)); }
public Task RemoveBadgeAsync(string id) { var partitionKey = MenuBadgeEntity.GeneratePartitionKey(); var rowKey = MenuBadgeEntity.GenerateRowKey(id); return(_tableStorage.DeleteAsync(partitionKey, rowKey)); }
public async Task <IAssetAvailabilityByMerchant> SetAsync(string paymentAssets, string settlementAssets, string merchantId) { string partitionKey = AssetAvailabilityByMerchantEntity.GeneratePartitionKey(merchantId); string rowKey = AssetAvailabilityByMerchantEntity.GenerateRowKey(merchantId); AssetAvailabilityByMerchantEntity exItem = await _tableStorage.GetDataAsync(partitionKey, rowKey); if (exItem != null && string.IsNullOrEmpty(settlementAssets) && string.IsNullOrEmpty(paymentAssets)) { await _tableStorage.DeleteAsync(exItem); return(null); } if (exItem != null) { exItem.PaymentAssets = paymentAssets; exItem.SettlementAssets = settlementAssets; await _tableStorage.InsertOrMergeAsync(exItem); return(exItem); } var newItem = AssetAvailabilityByMerchantEntity.Create(new AssetAvailabilityByMerchant { MerchantId = merchantId, PaymentAssets = paymentAssets, SettlementAssets = settlementAssets }); await _tableStorage.InsertAsync(newItem); return(newItem); }
public async Task <IKycDocument> DeleteAsync(string clientId, string documentId) { var partitionKey = KycDocumentEntity.GeneratePartitionKey(clientId); var rowKey = KycDocumentEntity.GenerateRowKey(documentId); return(await _tableStorage.DeleteAsync(partitionKey, rowKey)); }
public async Task <IProjectParticipateData> DeleteAsync(string projectId, string userId) { var partitionKey = ProjectParticipateEntity.GeneratePartitionKey(projectId); var rowKey = ProjectParticipateEntity.GenerateRowKey(userId); return(await _projectParticipateTableStorage.DeleteAsync(partitionKey, rowKey)); }
public async Task DeleteAsync(string blogId, string commentId) { var partitionKey = BlogCommentEntity.GeneratePartitionKey(blogId); var rowKey = BlogCommentEntity.GenerateRowKey(commentId); await _blogCommentsTableStorage.DeleteAsync(partitionKey, rowKey); }
public async Task DeleteAsync(string campaignId, string templateId = null) { var templates = string.IsNullOrEmpty(templateId) ? await _templateStorage.GetDataAsync(GetPartitionKey(campaignId)) : await _templateStorage.GetDataAsync(GetPartitionKey(campaignId), t => t.TemplateId == templateId); if (templates.Any()) { await _templateStorage.DeleteAsync(templates); } // if it's a campaign deletion then delete history too if (string.IsNullOrEmpty(templateId)) { var query = new TableQuery <EmailTemplateHistoryItemEntity>() .Where(TableQuery.GenerateFilterCondition(nameof(EmailTemplateHistoryItemEntity.CampaignId), QueryComparisons.Equal, campaignId)); var entities = new List <EmailTemplateHistoryItemEntity>(); await _templateHistoryStorage.ExecuteAsync(query, chunk => entities.AddRange(chunk)); if (entities.Any()) { await _templateHistoryStorage.DeleteAsync(entities); } } }
public Task DeleteAsync(IEnumerable <ICandle> candles) { return(_storage.DeleteAsync(candles.Select(c => new CandleEntity(c) { ETag = "*" }))); }
public async Task ReplaceAsync(string settlementId, IEnumerable <AssetSettlement> assetSettlements) { IEnumerable <AssetSettlementEntity> entities = await _storage.GetDataAsync(GetPartitionKey(settlementId)); await _storage.DeleteAsync(entities); await InsertAsync(assetSettlements); }
public Task DeleteAsync <T>(string traderId) where T : TraderSettingsBase, new() { var partitionKey = ClientSettingsEntity.GeneratePartitionKey(traderId); var defaultValue = TraderSettingsBase.CreateDefault <T>(); var rowKey = ClientSettingsEntity.GenerateRowKey(defaultValue); return(_tableStorage.DeleteAsync(partitionKey, rowKey)); }
public async Task <int> DeleteCandlesAsync(IReadOnlyList <ICandle> candlesToDelete, CandlePriceType priceType) { if (candlesToDelete == null || !candlesToDelete.Any()) { throw new ArgumentException("Candles set should not be empty."); } var partitionKey = CandleHistoryEntity.GeneratePartitionKey(priceType); // Splitting to chunks, just like in InsertOrMergeAsync var candleByRowsChunks = candlesToDelete .GroupBy(candle => CandleHistoryEntity.GenerateRowKey(candle.Timestamp, _timeInterval)) .Batch(100); int deletedCandlesCount = 0; foreach (var candleByRowsChunk in candleByRowsChunks) { var candleByRows = candleByRowsChunk.ToDictionary(g => g.Key, g => g.AsEnumerable()); var existingEntities = (await _tableStorage.GetDataAsync(partitionKey, candleByRows.Keys)) .ToList(); if (!existingEntities.Any()) // Safety check { continue; } var emptyEntities = new List <CandleHistoryEntity>(); foreach (var entity in existingEntities) { deletedCandlesCount += entity.DeleteCandles(candleByRows[entity.RowKey]); // There may be a case when all of the entities' candles were deleted. We need also to delete such an entity itself. if (!entity.Candles.Any()) { emptyEntities.Add(entity); } } foreach (var entity in emptyEntities) { existingEntities.Remove(entity); } // No _healthService trackig here. Monitoring of candles deletion is performed on upper layers of logic. if (emptyEntities.Any()) { await _tableStorage.DeleteAsync(emptyEntities); } await _tableStorage.InsertOrReplaceBatchAsync(existingEntities); // For we do not have a ReplaceBatchAsync method in AzureTableStorage yet. } return(deletedCandlesCount); }
public async Task RemoveAsync(string roleId) { var role = await GetAsync(roleId); if (role != null) { await _tableStorage.DeleteAsync(role as RoleEntity); } }
private async Task DeletePaymentRequestIdIndexAsync(InvoiceEntity entity) { if (string.IsNullOrEmpty(entity.PaymentRequestId)) { return; } await _paymentRequestIdIndexStorage.DeleteAsync(GetPaymentRequestIndexPartitionKey(entity.PaymentRequestId), GetPaymentRequestIndexRowKey()); }
private async Task <CashOutBaseEntity> ChangeStatus(string clientId, string requestId, CashOutRequestStatus status) { var entity = await _tableStorage.DeleteAsync(clientId, requestId); entity.PartitionKey = "Processed"; entity.Status = status; return(await _tableStorage.InsertAndGenerateRowKeyAsDateTimeAsync(entity, entity.DateTime)); }
private async Task <ICashOutRequest> ChangeStatus(string clientId, string requestId, CashOutRequestStatus status) { var entity = await _tableStorage.DeleteAsync(CashOutAttemptEntity.PendingRecords.GeneratePartition(clientId), CashOutAttemptEntity.PendingRecords.GenerateRowKey(requestId)); entity.PartitionKey = CashOutAttemptEntity.HistoryRecords.GeneratePartition(); entity.Status = status; return(await _tableStorage.InsertAndGenerateRowKeyAsDateTimeAsync(entity, entity.DateTime)); }