public Task <AsyncTaskResult> HandleAsync(GoodsStoreUpdatedEvent evnt) { return(TryTransactionAsync(async(connection, transaction) => { var info = evnt.Info; var effectedRows = await connection.UpdateAsync(new { Name = info.Name, Description = info.Description, Pics = info.Pics.ExpandAndToString("|"), Price = info.Price, OriginalPrice = info.OriginalPrice, Sort = info.Sort, Stock = info.Stock, Is7SalesReturn = info.Is7SalesReturn, IsInvoice = info.IsInvoice, IsPayOnDelivery = info.IsPayOnDelivery, Version = evnt.Version, EventSequence = evnt.Sequence }, new { Id = evnt.AggregateRootId, //Version = evnt.Version - 1 }, ConfigSettings.GoodsTable, transaction); //更新分类 var tasks = new List <Task>(); tasks.Add(connection.DeleteAsync(new { GoodsId = evnt.AggregateRootId }, ConfigSettings.GoodsPubCategorysTable, transaction)); //插入新的记录 foreach (var categoryId in evnt.CategoryIds) { tasks.Add(connection.InsertAsync(new { Id = GuidUtil.NewSequentialId(), GoodsId = evnt.AggregateRootId, CategoryId = categoryId }, ConfigSettings.GoodsPubCategorysTable, transaction)); } Task.WaitAll(tasks.ToArray()); })); }
private void Handle(GoodsStoreUpdatedEvent evnt) { _categoryIds = evnt.CategoryIds; var editableInfo = evnt.Info; _info = new GoodsInfo( editableInfo.Name, editableInfo.Description, editableInfo.Pics, editableInfo.Price, editableInfo.OriginalPrice, _info.Benevolence, editableInfo.Stock, _info.SellOut, editableInfo.IsPayOnDelivery, editableInfo.IsInvoice, editableInfo.Is7SalesReturn, editableInfo.Sort); }