コード例 #1
0
        public Task <AsyncTaskResult> HandleAsync(GoodsBlockUpdatedEvent evnt)
        {
            return(TryTransactionAsync(async(connection, transaction) =>
            {
                var effectedRows = await connection.UpdateAsync(new
                {
                    Name = evnt.Info.Name,
                    Thumb = evnt.Info.Thumb,
                    Banner = evnt.Info.Banner,
                    Layout = (int)evnt.Info.Layout,
                    IsShow = evnt.Info.IsShow,
                    Sort = evnt.Info.Sort,
                    Version = evnt.Version,
                    EventSequence = evnt.Sequence
                }, new
                {
                    Id = evnt.AggregateRootId,
                    //Version = evnt.Version - 1
                }, ConfigSettings.GoodsBlockTable, transaction);

                var tasks = new List <Task>();
                //删除原来的记录
                tasks.Add(connection.DeleteAsync(new
                {
                    GoodsBlockId = evnt.AggregateRootId
                }, ConfigSettings.GoodsBlockGoodsesTable, transaction));

                //插入新的记录
                foreach (var goodsId in evnt.Info.Goodses)
                {
                    tasks.Add(connection.InsertAsync(new
                    {
                        Id = GuidUtil.NewSequentialId(),
                        GoodsBlockId = evnt.AggregateRootId,
                        GoodsId = goodsId
                    }, ConfigSettings.GoodsBlockGoodsesTable, transaction));
                }
                Task.WaitAll(tasks.ToArray());
            }));
        }
コード例 #2
0
ファイル: GoodsBlock.cs プロジェクト: zanderphh/Shop
 private void Handle(GoodsBlockUpdatedEvent evnt)
 {
     _info = evnt.Info;
 }