public async Task HandleAsync(UserWithdrawFailedIntegrationEvent integrationEvent)
        {
            var userId = integrationEvent.UserId.ParseEntityId <UserId>();

            var transactionId = integrationEvent.Transaction.Id.ParseEntityId <TransactionId>();

            if (await _accountService.AccountExistsAsync(userId))
            {
                var account = await _accountService.FindAccountAsync(userId);

                var result = await _accountService.MarkAccountTransactionAsFailedAsync(account, transactionId);

                if (result.IsValid)
                {
                    _logger.LogInformation(""); // FRANCIS: TODO.
                }
                else
                {
                    _logger.LogError(""); // FRANCIS: TODO.
                }
            }
            else
            {
                _logger.LogWarning(""); // FRANCIS: TODO.
            }
        }
        public async Task HandleAsync(UserCreatedIntegrationEvent integrationEvent)
        {
            var userId = integrationEvent.UserId.ParseEntityId <UserId>();

            if (!await _accountService.AccountExistsAsync(userId))
            {
                var result = await _accountService.CreateAccountAsync(userId);

                if (result.IsValid)
                {
                    if (AppSettings?.IntegrationEvent?.UserCreated?.Promotion?.Enabled ?? false)
                    {
                        var account = await _accountService.FindAccountAsync(userId);

                        await _accountService.CreateTransactionAsync(
                            account,
                            AppSettings.IntegrationEvent.UserCreated.Promotion.Currency.Type.ToEnumeration <CurrencyType>()
                            .ToCurrency(AppSettings.IntegrationEvent.UserCreated.Promotion.Currency.Amount),
                            TransactionType.Promotion);
                    }

                    _logger.LogInformation(""); // FRANCIS: TODO.
                }
                else
                {
                    _logger.LogError(""); // FRANCIS: TODO.
                }
            }
            else
            {
                _logger.LogWarning(""); // FRANCIS: TODO.
            }
        }
        public async Task HandleAsync(UserStripePaymentIntentSucceededIntegrationEvent integrationEvent)
        {
            var userId = integrationEvent.UserId.ParseEntityId <UserId>();

            var transactionId = integrationEvent.TransactionId.ParseEntityId <TransactionId>();

            if (await _accountService.AccountExistsAsync(userId))
            {
                var account = await _accountService.FindAccountAsync(userId);

                var result = await _accountService.MarkAccountTransactionAsSucceededAsync(account, transactionId);

                if (result.IsValid)
                {
                    await _serviceBusPublisher.PublishUserDepositSucceededIntegrationEventAsync(userId, _mapper.Map <TransactionDto>(result.Response));

                    _logger.LogInformation(""); // FRANCIS: TODO.
                }
                else
                {
                    _logger.LogError(""); // FRANCIS: TODO.
                }
            }
            else
            {
                _logger.LogWarning(""); // FRANCIS: TODO.
            }
        }
예제 #4
0
        public async Task HandleAsync(ChallengeParticipantRegisteredIntegrationEvent integrationEvent)
        {
            var participant = integrationEvent.Participant;

            var userId = participant.UserId.ParseEntityId <UserId>();

            var participantId = participant.Id.ParseEntityId <ParticipantId>();

            var challengeId = participant.ChallengeId.ParseEntityId <ChallengeId>();

            if (await _accountService.AccountExistsAsync(userId))
            {
                var account = await _accountService.FindAccountAsync(userId);

                var metadata = new TransactionMetadata
                {
                    [nameof(ChallengeId)]   = challengeId,
                    [nameof(ParticipantId)] = participantId
                };

                var result = await _accountService.MarkAccountTransactionAsSucceededAsync(account, metadata);

                if (result.IsValid)
                {
                    _logger.LogInformation(""); // FRANCIS: TODO.
                }
                else
                {
                    _logger.LogError(""); // FRANCIS: TODO.
                }
            }
            else
            {
                _logger.LogCritical(""); // FRANCIS: TODO.
            }
        }