Beispiel #1
0
        private void ProcessPayment(PayAccount cmd)
        {
            try
            {
                var luckObligation = _accountState.Obligations.FirstOrDefault(x => x.Key == "AccountAdjustments").Value;
                if (luckObligation == null)
                {
                    throw new Exception($"[ProcessPayment]: Inconvibable! Why is there no obligation?");
                }

                var @event = new PaymentAppliedToObligation(
                    luckObligation.ObligationNumber
                    , new CreditCardPayment(cmd.AmountToPay)
                    , cmd.AmountToPay
                    , "CreditCard Payment Applied To Dues"
                    );
                Persist(@event, s =>
                {
                    _accountState = _accountState.ApplyEvent(@event);
                    Self.Tell(new PublishAccountStateToKafka());
                    ApplySnapShotStrategy();
                    Sender.Tell(new MyAccountStatus("Payment Applied", (AccountState)_accountState.Clone()));
                });
            }
            catch (Exception e)
            {
                _log.Error($"[ProcessPayment]: {e.Message} {e.StackTrace}");
                throw;
            }
        }