public Task <AsyncTaskResult> HandleAsync(SpecificationsUpdatedEvent evnt) { return(TryTransactionAsync(async(connection, transaction) => { var effectedRows = await connection.UpdateAsync(new { Version = evnt.Version, EventSequence = evnt.Sequence }, new { Id = evnt.AggregateRootId, //Version = evnt.Version - 1 }, ConfigSettings.GoodsTable, transaction); if (effectedRows == 1) { var tasks = new List <Task>(); //更新规格 foreach (var specification in evnt.Specifications) { tasks.Add(connection.UpdateAsync(new { Name = specification.Info.Name, Value = specification.Info.Value, Price = specification.Info.Price, OriginalPrice = specification.Info.OriginalPrice, Benevolence = specification.Info.Benevolence, Stock = specification.Stock, Number = specification.Info.Number, Thumb = specification.Info.Thumb, BarCode = specification.Info.BarCode, AvailableQuantity = specification.Stock }, new { Id = specification.Id, GoodsId = evnt.AggregateRootId }, ConfigSettings.SpecificationTable, transaction)); } Task.WaitAll(tasks.ToArray()); } })); }
private void Handle(SpecificationsUpdatedEvent evnt) { _specifications = evnt.Specifications; }