public Task <AsyncTaskResult> HandleAsync(SpecificationStockChangedEvent evnt) { return(TryTransactionAsync(async(connection, transaction) => { var effectedRows = await connection.UpdateAsync(new { EventSequence = evnt.Sequence }, new { Id = evnt.AggregateRootId, Version = evnt.Version, EventSequence = evnt.Sequence - 1 }, ConfigSettings.GoodsTable, transaction); if (effectedRows == 1) { await connection.UpdateAsync(new { Stock = evnt.Stock, AvailableQuantity = evnt.AvailableQuantity }, new { GoodsId = evnt.AggregateRootId, Id = evnt.SpecificationId }, ConfigSettings.SpecificationTable, transaction); } })); }
private void Handle(SpecificationStockChangedEvent evnt) { _specifications.Single(x => x.Id == evnt.SpecificationId).Stock = evnt.Stock; }