public Task <AsyncTaskResult> HandleAsync(CartRemovedGoodsEvent 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.DeleteAsync(new { CartId = evnt.AggregateRootId, Id = evnt.CartGoodsId }, ConfigSettings.CartGoodsesTable, transaction); } })); }
private void Handle(CartRemovedGoodsEvent evnt) { _cartGoodses.Remove(_cartGoodses.Single(x=>x.Id==evnt.CartGoodsId)); _goodsCount = evnt.FinalCount; }