Esempio n. 1
0
 public void SendCertificateOfAttendance(Guid studentId, Guid documentId)
 {
     GuidAssert.AreNotEmpty(studentId, documentId);
     if (!_bookedStudent.Contains(studentId))
     {
         throw new StudentNotInSessionException();
     }
     RaiseEvent(new CertificateOfAttendanceSent(AggregateId, GetNextSequence(), studentId, documentId));
 }
Esempio n. 2
0
        public void SignalAgreementAssociated(Guid agreementId, Guid seatId, Guid companyId)
        {
            GuidAssert.AreNotEmpty(agreementId, seatId, companyId);

            RaiseEvent(new AgreementAssociatedToSeatSignaled(AggregateId, GetNextSequence(), seatId, agreementId));

            if (_notifications.OfType <AgreementToSignNotificationSent>().All(a => a.CompanyId != companyId || a.AgreementId != agreementId))
            {
                RaiseEvent(new AgreementToSignNotificationSent(AggregateId, GetNextSequence(), _sessionId, companyId, agreementId, Guid.NewGuid()));
            }

            RemoveNotifications <AgreementToCreateNotificationSent>(a => a.CompanyId == companyId);
        }
Esempio n. 3
0
        public void SignalSeatValidated(Guid seatId, Guid companyId)
        {
            GuidAssert.AreNotEmpty(seatId, companyId);

            RaiseEvent(new ValidateSeatSignaled(AggregateId, GetNextSequence(), seatId));

            if (_notifications.OfType <AgreementToCreateNotificationSent>().All(a => a.CompanyId != companyId))
            {
                RaiseEvent(new AgreementToCreateNotificationSent(AggregateId, GetNextSequence(), _sessionId, companyId, Guid.NewGuid()));
            }

            RemoveNotifications <SeatToValidateNotificationSent>(a => a.SeatId == seatId);
        }
        public void Execute(Guid seatId, Guid?newStudentId)
        {
            GuidAssert.AreNotEmpty(seatId);

            var seat = GetAggregate <Seat>(seatId, true);

            seat.UpdateStudent(newStudentId);

            var notificationManagerId = _notificationQueries.GetNotificationManagerId(seat.SessionId);
            var notificationManager   = GetAggregate <NotificationManager>(notificationManagerId, true);

            notificationManager.SignalSeatRedefined(seatId, seat.CompanyId, newStudentId);

            PublishUncommitedEvents(seat, notificationManager);
        }
Esempio n. 5
0
        public void SignalSeatCreated(Guid seatId, Guid companyId, Guid?studentId, bool sendNotification = true)
        {
            GuidAssert.AreNotEmpty(seatId, companyId);

            RaiseEvent(new CreateSeatSignaled(AggregateId, GetNextSequence(), seatId, companyId));

            if (sendNotification && studentId.HasValue)
            {
                RaiseEvent(new SeatToValidateNotificationSent(AggregateId, GetNextSequence(), _sessionId, companyId, seatId, Guid.NewGuid()));
            }

            if (!studentId.HasValue)
            {
                RaiseEvent(new SeatToDefineStudentNotificationSent(AggregateId, GetNextSequence(), _sessionId, companyId, seatId, Guid.NewGuid()));
            }
        }
Esempio n. 6
0
        private void CancelOrRefuse(Guid seatId, Guid companyId, DomainEvent eventToRaise)
        {
            if (eventToRaise == null)
            {
                throw new ArgumentNullException(nameof(eventToRaise));
            }
            GuidAssert.AreNotEmpty(seatId, companyId);
            RaiseEvent(eventToRaise);

            if (!_seatStates.Any(a => a.CompanyId == companyId && a.Status == SeatStatus.Valid && !a.AssociatedAgreement.HasValue))
            {
                RemoveNotifications <AgreementToCreateNotificationSent>(a => a.CompanyId == companyId);
            }

            RemoveNotifications <SeatToValidateNotificationSent>(a => a.SeatId == seatId);
        }
Esempio n. 7
0
        public void SignalAgreementRevoked(Guid agreementId)
        {
            GuidAssert.AreNotEmpty(agreementId);

            RemoveNotifications <AgreementToSignNotificationSent>(a => a.AgreementId == agreementId);

            var companyId = _seatStates.FirstOrDefault(a => a.AssociatedAgreement == agreementId)?.CompanyId;

            if (!companyId.HasValue)
            {
                return;
            }

            if (_seatStates.Any(a => a.CompanyId == companyId && a.Status == SeatStatus.Valid))
            {
                RaiseEvent(new AgreementToCreateNotificationSent(AggregateId, GetNextSequence(), _sessionId, companyId.Value, Guid.NewGuid()));
            }
        }
Esempio n. 8
0
 public void SendTimesheet(Guid documentId)
 {
     GuidAssert.AreNotEmpty(documentId);
     RaiseEvent(new SessionTimesheetSent(AggregateId, GetNextSequence(), documentId));
 }
Esempio n. 9
0
 public void Remove(Guid notificationId)
 {
     GuidAssert.AreNotEmpty(notificationId);
     RaiseEvent(new NotificationRemoved(AggregateId, GetNextSequence(), notificationId));
 }
Esempio n. 10
0
 public void SignalAgreementSigned(Guid agreementId)
 {
     GuidAssert.AreNotEmpty(agreementId);
     RemoveNotifications <AgreementToSignNotificationSent>(a => a.AgreementId == agreementId);
 }