Beispiel #1
0
        public Task <AsyncTaskResult> HandleAsync(CartGoodsQuantityChangedEvent evnt)
        {
            return(TryTransactionAsync(async(connection, transaction) =>
            {
                var effectedRows = await connection.UpdateAsync(new
                {
                    GoodsCount = evnt.FinalCount,
                    Version = evnt.Version,
                    EventSequence = evnt.Sequence
                }, new
                {
                    Id = evnt.AggregateRootId,
                    //Version = evnt.Version - 1
                }, ConfigSettings.CartTable, transaction);

                if (effectedRows == 1)
                {
                    await connection.UpdateAsync(new
                    {
                        Quantity = evnt.FinalQuantity
                    }, new
                    {
                        CartId = evnt.AggregateRootId,
                        Id = evnt.CartGoodsId
                    }, ConfigSettings.CartGoodsesTable, transaction);
                }
            }));
        }
Beispiel #2
0
 private void Handle(CartGoodsQuantityChangedEvent evnt)
 {
     _cartGoodses.Single(x => x.Id == evnt.CartGoodsId).Info.Quantity = evnt.FinalQuantity;
     _goodsCount = evnt.FinalCount;
 }