public Task <AsyncTaskResult> HandleAsync(SpecificationReservationCancelledEvent evnt) { return(_messagePublisher.PublishAsync(new SpecificationReservationCancelledMessage ( evnt.AggregateRootId, evnt.ReservationId ))); }
public Task <AsyncTaskResult> HandleAsync(SpecificationReservationCancelledEvent 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>(); //删除预定记录 tasks.Add(connection.DeleteAsync(new { GoodsId = evnt.AggregateRootId, ReservationId = evnt.ReservationId }, ConfigSettings.ReservationItemsTable, transaction)); //更新规格的可用数量 foreach (var specificationAvailableQuantity in evnt.SpecificationAvailableQuantities) { tasks.Add(connection.UpdateAsync(new { AvailableQuantity = specificationAvailableQuantity.AvailableQuantity }, new { GoodsId = evnt.AggregateRootId, Id = specificationAvailableQuantity.SpecificationId }, ConfigSettings.SpecificationTable, transaction)); } Task.WaitAll(tasks.ToArray()); } })); }
/// <summary> /// 每个商品都会发送一个取消命令 /// </summary> /// <param name="message"></param> /// <returns></returns> public Task <AsyncTaskResult> HandleAsync(SpecificationReservationCancelledEvent evnt) { return(_commandService.SendAsync(new CloseOrderCommand(evnt.ReservationId, evnt.AggregateRootId))); }
private void Handle(SpecificationReservationCancelledEvent evnt) { _reservations.Remove(evnt.ReservationId); }