Skip to content

Commit

Permalink
ExistsByEmailAndEventId
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavofg1pontes committed Oct 7, 2024
1 parent 6a13b80 commit 31da3b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public CreateEnrollmentOutput execute(CreateEnrollmentInput anIn) {
if (!event.getStatus().equals(EventStatus.OPENED))
Notification.create("Event is not opened").append("Event is not open for enrollment").throwPossibleErrors();

alreadyExists = this.enrollmentGateway.existsByDocumentAndEventID(document, eventID);
alreadyExists = this.enrollmentGateway.existsByEmailAndEventID(emailString, eventID);
System.out.println(alreadyExists);
if (alreadyExists) {
Notification.create("Validation Error").append("User already enrolled in this event").throwPossibleErrors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public interface IEnrollmentGateway {

boolean existsByUserIDAndEventID(UserID userID, EventID eventID);
boolean existsByDocumentAndEventID(String document, EventID eventID);
boolean existsByEmailAndEventID(String document, EventID eventID);

Enrollment update(Enrollment enrollment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public boolean existsByDocumentAndEventID(String document, EventID eventID) {
return this.enrollmentRepository.existsByDocumentAndEventID(document, eventID.getValue());
}

@Override
public boolean existsByEmailAndEventID(String document, EventID eventID) {
return this.enrollmentRepository.existsByEmailAndEventID(document, eventID.getValue());
}

@Override
public Enrollment update(Enrollment enrollment) {
return this.enrollmentRepository.save(EnrollmentJpaEntity.from(enrollment)).toAggregate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public interface EnrollmentRepository extends JpaRepository<EnrollmentJpaEntity,
Optional<EnrollmentJpaEntity> findByUserIDAndEventID(UUID userID, UUID eventID);
boolean existsByUserIDAndEventID(UUID userID, UUID eventID);
boolean existsByDocumentAndEventID(String document, UUID eventID);
boolean existsByEmailAndEventID(String email, UUID eventID);
}

0 comments on commit 31da3b8

Please sign in to comment.