public async Task <IEnumerable <IHistoryOperation> > GetByInvoiceAsync(string invoiceId)
        {
            IEnumerable <AzureIndex> indexes = await _indexByInvoice.GetDataAsync(
                IndexByInvoice.GeneratePartitionKey(invoiceId));

            return(await _storage.GetDataAsync(indexes));
        }
        public Task InsertOrReplaceAsync(IHistoryOperation historyOperation)
        {
            var entity = new HistoryOperationEntity(historyOperation);

            var tasks = new List <Task>();

            tasks.Add(_storage.InsertOrReplaceAsync(entity));

            AzureIndex indexById = IndexById.Create(entity);

            tasks.Add(_indexById.InsertOrReplaceAsync(indexById));

            if (!string.IsNullOrEmpty(historyOperation.InvoiceId))
            {
                AzureIndex indexByInvoice = IndexByInvoice.Create(entity);
                tasks.Add(_indexByInvoice.InsertOrReplaceAsync(indexByInvoice));
            }

            return(Task.WhenAll(tasks));
        }