public Task <AsyncTaskResult> HandleAsync(GoodsBlockWarpUpdatedEvent evnt) { return(TryTransactionAsync(async(connection, transaction) => { var effectedRows = await connection.UpdateAsync(new { Name = evnt.Info.Name, Style = (int)evnt.Info.Style, IsShow = evnt.Info.IsShow, Sort = evnt.Info.Sort, Version = evnt.Version, EventSequence = evnt.Sequence }, new { Id = evnt.AggregateRootId, //Version = evnt.Version - 1 }, ConfigSettings.GoodsBlockWarpTable, transaction); var tasks = new List <Task>(); //删除原来的记录 tasks.Add(connection.DeleteAsync(new { GoodsBlockWarpId = evnt.AggregateRootId }, ConfigSettings.GoodsBlockWarpGoodsBlocksTable, transaction)); //插入新的记录 foreach (var goodsBlockId in evnt.Info.GoodsBlocks) { tasks.Add(connection.InsertAsync(new { Id = GuidUtil.NewSequentialId(), GoodsBlockWarpId = evnt.AggregateRootId, GoodsBlockId = goodsBlockId }, ConfigSettings.GoodsBlockWarpGoodsBlocksTable, transaction)); } Task.WaitAll(tasks.ToArray()); })); }
private void Handle(GoodsBlockWarpUpdatedEvent evnt) { _info = evnt.Info; }