Ejemplo n.º 1
0
        public void Execute(Guid seatId, string reason)
        {
            var seat = GetAggregate <Seat>(seatId);

            seat.Refuse(reason);

            var managerId = _notificationManagerQueries.GetNotificationManagerId(seat.SessionId);
            var manager   = GetAggregate <NotificationManager>(managerId);

            manager.SignalSeatRefused(seatId, seat.CompanyId);

            Agreement agreement = null;

            if (seat.AssociatedAgreementId.HasValue)
            {
                agreement = GetAggregate <Agreement>(seat.AssociatedAgreementId.Value);
                agreement.Revoke();
                manager.SignalAgreementRevoked(agreement.AggregateId);
            }

            var session = GetAggregate <Session>(seat.SessionId);

            if (seat.StudentId.HasValue)
            {
                session.ReleaseSeat(seat.StudentId.Value);
            }

            PublishUncommitedEvents(seat, agreement, session, manager);
        }