Exemple #1
0
        public async Task <IPaymentTransaction> GetLastByDateAsync(string clientId)
        {
            var partitionKey = PaymentTransactionEntity.GeneratePartitionKey(clientId);
            var entities     = await _tableStorage.GetDataAsync(partitionKey);

            return(entities.OrderByDescending(itm => itm.Created).FirstOrDefault());
        }
Exemple #2
0
        public async Task InsertAsync(IPaymentTransaction paymentTransaction)
        {
            var commonEntity = Mapper.Map <PaymentTransactionEntity>(paymentTransaction);

            commonEntity.PartitionKey = PaymentTransactionEntity.GeneratePartitionKey();
            await _tableStorage.InsertAndGenerateRowKeyAsDateTimeAsync(commonEntity, paymentTransaction.Created);

            var entityByClient = Mapper.Map <PaymentTransactionEntity>(paymentTransaction);

            entityByClient.PartitionKey = PaymentTransactionEntity.GeneratePartitionKey(paymentTransaction.ClientId);
            entityByClient.RowKey       = PaymentTransactionEntity.GenerateRowKey(paymentTransaction.Id);

            var index = AzureMultiIndex.Create(IndexPartitionKey, paymentTransaction.Id, commonEntity, entityByClient);

            await Task.WhenAll(
                _tableStorage.InsertAsync(entityByClient),
                _tableStorageIndices.InsertAsync(index)
                );
        }