Пример #1
0
        public void Handle(AccountValueChanged evt)
        {
            if (!evt.SagaId.HasValue)
            {
                return;
            }

            var creating = sagas.GetById <AccountValueTranferring>(evt.SagaId.Value);

            creating.Transition(evt);
            Save(creating, @by: evt);
        }
Пример #2
0
        void Apply(AccountValueChanged evt)
        {
            value += evt.ValueDifference;

            if (evt.SagaId.HasValue)
            {
                Guid    transactionId = evt.SagaId.Value;
                decimal transferredValue;
                transferredValues.TryGetValue(transactionId, out transferredValue);
                transferredValue += evt.ValueDifference;
                transferredValues[transactionId] = transferredValue;
            }
        }
Пример #3
0
        void Apply(AccountValueChanged evt)
        {
            if (failed)
            {
                return;
            }

            if (evt.Id == from)
            {
                Dispatch(new ChangeAccountValue {
                    Id = to, Value = transferredValue
                });
            }
            if (evt.Id == to)
            {
                // Tranferring is completed
            }
        }