protected override bool ExecuteRemovePendingRequest(Party requestorParty)
 {
     return(AzureStorageHelper.DeleteEntry <PartyEntity>(
                _partiesTable,
                PartyEntity.CreatePartitionKey(requestorParty, PartyEntityType.PendingRequest),
                PartyEntity.CreateRowKey(requestorParty)));
 }
 protected override bool ExecuteRemoveParty(Party partyToRemove, bool isUser)
 {
     return(AzureStorageHelper.DeleteEntry <PartyEntity>(
                _partiesTable,
                PartyEntity.CreatePartitionKey(partyToRemove, isUser ? PartyEntityType.User : PartyEntityType.Bot),
                PartyEntity.CreateRowKey(partyToRemove)));
 }
        protected override bool ExecuteRemoveAggregationParty(Party aggregationPartyToRemove)
        {
            var partyEntitiesToRemove = GetPartyEntitiesByPropertyNameAndValue(
                PartitionKey,
                PartyEntity.CreatePartitionKey(aggregationPartyToRemove, PartyEntityType.Aggregation))
                                        .FirstOrDefault();

            return(AzureStorageHelper.DeleteEntry <PartyEntity>(
                       _partiesTable, partyEntitiesToRemove.PartitionKey, partyEntitiesToRemove.RowKey));
        }
        public override void DeleteAll()
        {
            base.DeleteAll();

            try
            {
                var partyEntities = _partiesTable.ExecuteQuery(new TableQuery <PartyEntity>());

                foreach (var partyEntity in partyEntities)
                {
                    AzureStorageHelper.DeleteEntry <PartyEntity>(
                        _partiesTable, partyEntity.PartitionKey, partyEntity.RowKey);
                }
            }
            catch (StorageException e)
            {
                System.Diagnostics.Debug.WriteLine($"Failed to delete entries: {e.Message}");
                return;
            }

            var connectionEntities = _connectionsTable.ExecuteQuery(new TableQuery <ConnectionEntity>());

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

            /*
             * try
             * {
             *  _partiesTable.Delete();
             * }
             * catch (Exception e)
             * {
             *  System.Diagnostics.Debug.WriteLine($"An error occured while trying to delete the parties table: {e.Message}");
             * }
             *
             * try
             * {
             *  _connectionsTable.Delete();
             * }
             * catch (Exception e)
             * {
             *  System.Diagnostics.Debug.WriteLine($"An error occured while trying to delete the connections table: {e.Message}");
             * }
             */
        }
        protected override bool ExecuteRemoveConnection(Party conversationOwnerParty)
        {
            Dictionary <Party, Party> connectedParties = GetConnectedParties();

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

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

            return(false);
        }