public async Task SetBalanceAsync(string ownerId, string ownerType, decimal newBalance)
        {
            var oldBalance = await m_Database.GetBalanceAsync(ownerId, ownerType);

            await m_Database.SetBalanceAsync(ownerId, ownerType, newBalance);

            var getBalanceEvent =
                new BalanceUpdatedEvent(ownerId, ownerType, oldBalance, newBalance, "Set Balance Requested");
            await m_EventBus.EmitAsync(EconomyPlugin.Instance, this, getBalanceEvent);
        }
        public async Task SetBalanceAsync(string ownerId, string ownerType, decimal newBalance)
        {
            var oldBalance = await m_Database.GetBalanceAsync(ownerId, ownerType);

            await m_Database.SetBalanceAsync(ownerId, ownerType, newBalance);

            var getBalanceEvent =
                new BalanceUpdatedEvent(ownerId, ownerType, oldBalance, newBalance, "Set Balance Requested");
            await EventBus.EmitAsync(OpenModComponent, this, getBalanceEvent);
        }
示例#3
0
        public async Task Handle(BalanceUpdatedEvent evt)
        {
            await _cachedWalletsRepository.UpdateBalanceAsync(
                evt.WalletId,
                evt.AssetId,
                decimal.Parse(evt.Balance),
                decimal.Parse(evt.Reserved),
                evt.SequenceNumber);

            _chaosKitty.Meow("Problem with Azure Table Storage");
        }
示例#4
0
 public async Task Handle(
     BalanceUpdatedEvent evt)
 {
     if (evt.AssetId == _neoAssetId)
     {
         await _balanceService.RegisterBalanceUpdateAsync
         (
             walletId : Guid.Parse(evt.WalletId),
             eventTimestamp : evt.Timestamp,
             newBalance : decimal.Parse(evt.Balance)
         );
     }
 }
        public async Task <decimal> UpdateBalanceAsync(string ownerId, string ownerType, decimal amount, string reason)
        {
            if (amount == 0)
            {
                throw new UserFriendlyException(StringLocalizer["economy:fail:invalid_amount",
                                                                new { Amount = amount }]);
            }

            var oldBalance = await m_Database.GetBalanceAsync(ownerId, ownerType);

            var balance = await m_Database.UpdateBalanceAsync(ownerId, ownerType, amount, reason);

            var getBalanceEvent = new BalanceUpdatedEvent(ownerId, ownerType, oldBalance, balance, reason);
            await m_EventBus.EmitAsync(EconomyPlugin.Instance, this, getBalanceEvent);

            return(balance);
        }
示例#6
0
 public override void Handle(BalanceUpdatedEvent message)
 {
     base.Handle(message);
     this.NotifyProperties();
 }
示例#7
0
 public void Apply(BalanceUpdatedEvent domainEvent)
 {
     Console.WriteLine("Apply BalanceUpdatedEvent {0}", domainEvent.Balance);
     this.balance = domainEvent.Balance;
 }
示例#8
0
        private void OnPostBalanceUpdated(string id, decimal increaseBy, decimal amt)
        {
            var @event = new BalanceUpdatedEvent(id, KnownActorTypes.Player, amt - increaseBy, amt, null);

            AsyncHelper.RunSync(() => m_EventBus.EmitAsync(m_RocketModComponent, this, @event));
        }