public Task <AsyncTaskResult> HandleAsync(CartAddedGoodsEvent 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.InsertAsync(new { Id = evnt.CartGoodsId, CartId = evnt.AggregateRootId, StoreId = evnt.Info.StoreId, GoodsId = evnt.Info.GoodsId, SpecificationId = evnt.Info.SpecificationId, SpecificationName = evnt.Info.SpecificationName, GoodsName = evnt.Info.GoodsName, GoodsPic = evnt.Info.GoodsPic, Price = evnt.Info.Price, OriginalPrice = evnt.Info.OriginalPrice, Stock = evnt.Info.Stock, Quantity = evnt.Info.Quantity, Benevolence = evnt.Info.Benevolence, CreatedOn = evnt.Timestamp }, ConfigSettings.CartGoodsesTable, transaction); } })); }
private void Handle(CartAddedGoodsEvent evnt) { _cartGoodses.Add(new CartGoods(evnt.CartGoodsId,evnt.Info)); _goodsCount = evnt.FinalCount; }