Exemplo n.º 1
0
        public async Task ConfirmAsync(Guid transferId)
        {
            var transfer = await _transfersService.GetByIdAsync(transferId);

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

            var evt = new VoucherTokensReservedEvent
            {
                TransferId  = transferId,
                CustomerId  = transfer.CustomerId,
                SpendRuleId = transfer.SpendRuleId,
                Amount      = transfer.Amount,
                Timestamp   = transfer.Created,
                VoucherId   = transfer.VoucherId,
            };
            await _voucherTokensReservedEventPublisher.PublishAsync(evt);

            await _vouchersService.SellAsync(transfer.VoucherId);

            await _transfersService.CompleteAsync(transferId);
        }