public Task <AsyncTaskResult> HandleAsync(SeatsReservationCommitted evnt) { return(_messagePublisher.PublishAsync(new SeatsReservationCommittedMessage { ConferenceId = evnt.AggregateRootId, ReservationId = evnt.ReservationId })); }
public Task HandleAsync(SeatsReservationCommitted 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.ConferenceTable, transaction); if (effectedRows == 1) { var tasks = new List <Task>(); //删除预定记录 tasks.Add(connection.DeleteAsync(new { ConferenceId = evnt.AggregateRootId, ReservationId = evnt.ReservationId }, ConfigSettings.ReservationItemsTable, transaction)); //更新位置的数量 foreach (var seatQuantity in evnt.SeatQuantities) { tasks.Add(connection.UpdateAsync(new { Quantity = seatQuantity.Quantity }, new { ConferenceId = evnt.AggregateRootId, Id = seatQuantity.SeatTypeId }, ConfigSettings.SeatTypeTable, transaction)); } await Task.WhenAll(tasks); } })); }
private void OnSeatsReservationCommitted(SeatsReservationCommitted e) { pendingReservations.Remove(e.ReservationId); }
private void OnReservationCommitted(SeatsReservationCommitted @event) => _pendingReservations.Remove(@event.ReservationId);