protected override bool ExecuteRemoveAggregationParty(Party aggregationPartyToRemove)
 {
     return(AzureStorageHelper.DeleteEntryAsync <PartyEntity>(
                _aggregationPartiesTable,
                PartyEntity.CreatePartitionKey(aggregationPartyToRemove, PartyEntityType.Aggregation),
                PartyEntity.CreateRowKey(aggregationPartyToRemove)).Result);
 }
 protected override bool ExecuteRemovePendingRequest(Party requestorParty)
 {
     return(AzureStorageHelper.DeleteEntryAsync <PartyEntity>(
                _pendingRequestsTable,
                PartyEntity.CreatePartitionKey(requestorParty, PartyEntityType.PendingRequest),
                PartyEntity.CreateRowKey(requestorParty)).Result);
 }
 protected override bool ExecuteRemoveParty(Party partyToRemove, bool isUser)
 {
     return(AzureStorageHelper.DeleteEntryAsync <PartyEntity>(
                isUser ? _userPartiesTable : _botPartiesTable,
                PartyEntity.CreatePartitionKey(partyToRemove, isUser ? PartyEntityType.User : PartyEntityType.Bot),
                PartyEntity.CreateRowKey(partyToRemove)).Result);
 }
        public bool RemoveConnectionRequest(ConnectionRequest connectionRequest)
        {
            string rowKey = connectionRequest.Requestor.Conversation.Id;

            return(AzureStorageHelper.DeleteEntryAsync <RoutingDataEntity>(
                       _connectionRequestsTable, DefaultPartitionKey, rowKey).Result);
        }
        public bool RemoveAggregationChannel(ConversationReference aggregationChannel)
        {
            string rowKey = aggregationChannel.Conversation.Id;

            return(AzureStorageHelper.DeleteEntryAsync <RoutingDataEntity>(
                       _aggregationChannelsTable, DefaultPartitionKey, rowKey).Result);
        }
        public bool RemoveConnection(Connection connection)
        {
            string rowKey = connection.ConversationReference1.Conversation.Id +
                            connection.ConversationReference2.Conversation.Id;

            return(AzureStorageHelper.DeleteEntryAsync <RoutingDataEntity>(
                       _connectionsTable, DefaultPartitionKey, rowKey).Result);
        }
        protected override bool ExecuteRemoveConnection(Party conversationOwnerParty)
        {
            Dictionary <Party, Party> connectedParties = GetConnectedParties();

            if (connectedParties != null && connectedParties.Remove(conversationOwnerParty))
            {
                Party conversationClientParty = GetConnectedCounterpart(conversationOwnerParty);

                return(AzureStorageHelper.DeleteEntryAsync <ConnectionEntity>(
                           _connectionsTable,
                           conversationClientParty.ConversationAccount.Id,
                           conversationOwnerParty.ConversationAccount.Id).Result);
            }

            return(false);
        }
        public bool RemoveConversationReference(ConversationReference conversationReference)
        {
            CloudTable table = null;

            if (conversationReference.Bot != null)
            {
                table = _botInstancesTable;
            }
            else
            {
                table = _usersTable;
            }

            string rowKey = conversationReference.Conversation.Id;

            return(AzureStorageHelper.DeleteEntryAsync <RoutingDataEntity>(
                       table, DefaultPartitionKey, rowKey).Result);
        }
        public override async void DeleteAll()
        {
            base.DeleteAll();

            CloudTable[] cloudTables =
            {
                _botPartiesTable,
                _userPartiesTable,
                _aggregationPartiesTable,
                _connectionsTable
            };

            foreach (CloudTable cloudTable in cloudTables)
            {
                try
                {
                    var partyEntities = await GetPartyEntitiesAsync(cloudTable);

                    foreach (var partyEntity in partyEntities)
                    {
                        await AzureStorageHelper.DeleteEntryAsync <PartyEntity>(
                            cloudTable, partyEntity.PartitionKey, partyEntity.RowKey);
                    }
                }
                catch (StorageException e)
                {
                    System.Diagnostics.Debug.WriteLine($"Failed to delete entries from table '{cloudTable.Name}': {e.Message}");
                    return;
                }
            }

            var connectionEntities = await GetConnectionEntitiesAsync();

            foreach (var connectionEntity in connectionEntities)
            {
                await AzureStorageHelper.DeleteEntryAsync <ConnectionEntity>(
                    _connectionsTable, connectionEntity.PartitionKey, connectionEntity.RowKey);
            }
        }