Beispiel #1
0
        private void Handle(GiftcardRedeemed message)
        {
            var previousTransaction = this.readStore.GiftcardTransactions.Last(g => g.CardId == message.CardId);
            var newRevision         = previousTransaction.Revision;

            newRevision++;

            this.readStore.GiftcardTransactions.Add(new GiftcardTransaction
            {
                CardId     = message.CardId,
                CardNumber = previousTransaction.CardNumber,
                ValutaDate = DateTime.Today,
                Event      = message.GetType().Name,
                Balance    = previousTransaction.Balance - message.Amount,
                Amount     = message.Amount,
                Revision   = newRevision
            });
        }
Beispiel #2
0
 private void Apply(GiftcardRedeemed @event)
 {
     this.balance -= @event.Amount;
 }
Beispiel #3
0
 public Task HandleAsync(GiftcardRedeemed message)
 {
     return(Task.Run(() => this.Handle(message)));
 }
        private void Handle(GiftcardRedeemed message)
        {
            var giftcard = this.readStore.GiftcardOverviews.Single(g => g.CardId == message.CardId);

            giftcard.CurrentBalance -= message.Amount;
        }