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)); }
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); }
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); }
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())); } }
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); }
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())); } }
public void SendTimesheet(Guid documentId) { GuidAssert.AreNotEmpty(documentId); RaiseEvent(new SessionTimesheetSent(AggregateId, GetNextSequence(), documentId)); }
public void Remove(Guid notificationId) { GuidAssert.AreNotEmpty(notificationId); RaiseEvent(new NotificationRemoved(AggregateId, GetNextSequence(), notificationId)); }
public void SignalAgreementSigned(Guid agreementId) { GuidAssert.AreNotEmpty(agreementId); RemoveNotifications <AgreementToSignNotificationSent>(a => a.AgreementId == agreementId); }