示例#1
0
 public Task <AsyncTaskResult> HandleAsync(SeatsReservationCommitted evnt)
 {
     return(_messagePublisher.PublishAsync(new SeatsReservationCommittedMessage
     {
         ConferenceId = evnt.AggregateRootId,
         ReservationId = evnt.ReservationId
     }));
 }
示例#2
0
        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);
                }
            }));
        }
示例#3
0
 private void OnSeatsReservationCommitted(SeatsReservationCommitted e)
 {
     pendingReservations.Remove(e.ReservationId);
 }
示例#4
0
 private void OnReservationCommitted(SeatsReservationCommitted @event) =>
 _pendingReservations.Remove(@event.ReservationId);