public Guid Add(AddBankData data) { var validationResult = _bankQueries.ValidateCanAdd(data); if (!validationResult.IsValid) throw new RegoValidationException(validationResult); var bank = Mapper.Map<AFT.RegoV2.Core.Payment.Data.Bank>(data); bank.Id = data.Id ?? Guid.NewGuid(); bank.Created = DateTime.Now; bank.CreatedBy = _actorInfoProvider.Actor.UserName; using (var scope = CustomTransactionScope.GetTransactionScope()) { _repository.Banks.Add(bank); _repository.SaveChanges(); var bankAdded = new BankAdded { Id = bank.Id, BankId = bank.BankId, BrandId = bank.BrandId, Name = bank.BankName, CreatedDate = bank.Created }; _eventBus.Publish(bankAdded); scope.Complete(); } return bank.Id; }
public void Consume(BankAdded message) { _playerRepository.Banks.Add(new Bank { Id = message.Id, BankId = message.BankId, BankName = message.Name, BrandId = message.BrandId }); _playerRepository.SaveChanges(); }
public async Task AddAccounts(AddAccounts command) { try { var exchangeTokenResponse = await _plaid.ExchangeToken(command.PublicToken, _tokenSource.Token); if (exchangeTokenResponse != null && !string.IsNullOrEmpty(exchangeTokenResponse.AccessToken)) { List <IEvent> events = new List <IEvent>(); var bankAddedEvent = new BankAdded(command.BankId, command.BankName, exchangeTokenResponse.AccessToken, command.BoardId); events.Add(bankAddedEvent); var config = _settings.Get <TransactionWebhookConfig>(TransactionWebhookConfig.SettingsPrefix); var url = config.Url.Replace("{boardid}", command.BoardId); var webhookResponse = await _plaid.UpdateWebhook(exchangeTokenResponse.AccessToken, url, _tokenSource.Token); var bankWebhookAdded = new BankWebhookAdded(command.BankId, webhookResponse?.Item?.Webhook, command.BoardId); events.Add(bankWebhookAdded); var authResponse = await _plaid.RetrieveBalances(exchangeTokenResponse.AccessToken, _tokenSource.Token); if (authResponse?.Accounts?.Any() ?? false) { var accountAddedEvents = authResponse.Accounts.Select(a => new AccountAdded(command.BoardId, exchangeTokenResponse.AccessToken, a.AccountId, command.BankName, command.BankId, a.Name, a.Type, a.OfficialName, a.SubType, a.Balances.Available, a.Balances.Current, a.Balances.Limit) ); events.AddRange(accountAddedEvents); RaiseEvents(events); } } } catch (Exception ex) { throw; } }
public void Consume(BankAdded message) { _eventHandlers.Handle(message); }
public void Handle(BankAdded @event) { AddActivityLog(AdminActivityLogCategory.Bank, @event); }
public void Apply(BankAdded e) { Banks[e.Id] = new Bank(e.Id, e.Name, e.AccessToken, e.Timestamp); }