コード例 #1
0
        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());
            }));
        }
コード例 #2
0
ファイル: GoodsBlockWarp.cs プロジェクト: zanderphh/Shop
 private void Handle(GoodsBlockWarpUpdatedEvent evnt)
 {
     _info = evnt.Info;
 }