Beispiel #1
0
        public async Task HandleSucceededTransferAsync(Guid transferId)
        {
            var operation = await _operationsRepository.GetByTransferIdAsync(transferId, OperationType.Accept);

            if (operation == null)
            {
                return;
            }

            await _operationsRepository.UpdateAsync(operation.Id, OperationStatus.Succeeded);

            var transfer = await _transfersRepository.GetByIdAsync(operation.TransferId);

            if (transfer == null)
            {
                throw new TransferNotFoundException();
            }

            var evt = new VoucherTokensUsedEvent
            {
                TransferId  = operation.TransferId,
                CustomerId  = transfer.CustomerId,
                SpendRuleId = transfer.SpendRuleId,
                Amount      = transfer.Amount,
                Timestamp   = transfer.Created,
                VoucherId   = transfer.VoucherId,
            };
            await _voucherTokensUsedEventPublisher.PublishAsync(evt);

            _log.Info("Operation completed.", context:
                      $"transferId: {operation.Id}; type: {operation.Type}; transferId: {operation.TransferId}");
        }
Beispiel #2
0
 public Task <Transfer> GetByIdAsync(Guid transferId)
 {
     return(_transfersRepository.GetByIdAsync(transferId));
 }