Exemple #1
0
        public async Task HandleAsync(BalanceDecreased @event)
        {
            if (!await _cardsStore.ExistsAsync(@event.CardId.Value))
            {
                return;
            }

            var card = await _cardsStore.GetAsync(@event.CardId.Value);

            card.ChangeBalance(@event.Balance.Amount, (Currency)@event.Balance.Currency);
            card.ChangeTimestamp(_clock.Now.DateTime);

            await _cardsStore.UpdateAsync(card);

            _logger.LogDebug($"Card {@event.UserId} balance decreased.");
        }
Exemple #2
0
 private void When(BalanceDecreased @event)
 {
     _balance = @event.Balance;
 }