Esempio n. 1
0
 private void Handle(GoodsDeletedEvent evnt)
 {
     _categoryIds    = null;
     _reservations   = null;
     _info           = null;
     _commentIds     = null;
     _goodsParams    = null;
     _specifications = null;
 }
Esempio n. 2
0
        public Task <AsyncTaskResult> HandleAsync(GoodsDeletedEvent evnt)
        {
            return(TryTransactionAsync(async(connection, transaction) =>
            {
                var effectedRows = await connection.DeleteAsync(new
                {
                    Id = evnt.AggregateRootId,
                    //Version = evnt.Version - 1
                }, ConfigSettings.GoodsTable, transaction);

                if (effectedRows == 1)
                {
                    var tasks = new List <Task>();
                    //删除规格
                    tasks.Add(connection.DeleteAsync(new
                    {
                        GoodsId = evnt.AggregateRootId
                    }, ConfigSettings.SpecificationTable, transaction));
                    //删除参数
                    tasks.Add(connection.DeleteAsync(new
                    {
                        GoodsId = evnt.AggregateRootId
                    }, ConfigSettings.GoodsParamTable, transaction));
                    //删除所属分类
                    tasks.Add(connection.DeleteAsync(new
                    {
                        GoodsId = evnt.AggregateRootId
                    }, ConfigSettings.GoodsPubCategorysTable, transaction));
                    //删除评价
                    tasks.Add(connection.DeleteAsync(new
                    {
                        GoodsId = evnt.AggregateRootId
                    }, ConfigSettings.GoodsCommentsTable, transaction));

                    Task.WaitAll(tasks.ToArray());
                }
            }));
        }