Esempio n. 1
0
        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);
                }
            }));
        }
Esempio n. 2
0
 private void Handle(SpecificationStockChangedEvent evnt)
 {
     _specifications.Single(x => x.Id == evnt.SpecificationId).Stock = evnt.Stock;
 }