public Task <AsyncTaskResult> HandleAsync(SpecificationAddedEvent 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) { await connection.InsertAsync(new { Id = evnt.SpecificationId, GoodsId = evnt.AggregateRootId, Name = evnt.SpecificationInfo.Name, Value = evnt.SpecificationInfo.Value, Thumb = evnt.SpecificationInfo.Thumb, Price = evnt.SpecificationInfo.Price, OriginalPrice = evnt.SpecificationInfo.OriginalPrice, Benevolence = evnt.SpecificationInfo.Benevolence, Number = evnt.SpecificationInfo.Number, BarCode = evnt.SpecificationInfo.BarCode, Stock = evnt.Stock, AvailableQuantity = evnt.Stock, }, ConfigSettings.SpecificationTable, transaction); } })); }
private void Handle(SpecificationAddedEvent evnt) { _specifications.Add(new Specification(evnt.SpecificationId, evnt.SpecificationInfo, evnt.Stock)); }