Skip to content

Commit

Permalink
feat: event in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
oproprioleonardo committed Sep 28, 2024
1 parent 12060c8 commit 0524f6f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public CreateEnrollmentOutput execute(CreateEnrollmentInput anIn) {
final Event event = this.eventGateway.findById(eventID).orElseThrow(() -> NotFoundException.with(Event.class, eventID));
final Company company = this.companyGateway.findById(event.getCompanyID()).orElseThrow(() -> NotFoundException.with(Company.class, event.getCompanyID()));

if(!event.getStatus().equals(EventStatus.OPENED))
if (!event.getStatus().equals(EventStatus.OPENED))
Notification.create("Event is not opened").append("Event is not open for enrollment").throwPossibleErrors();

if (user != null) {
Expand Down
13 changes: 13 additions & 0 deletions domain/src/main/java/br/com/ifsp/tickets/domain/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void changeStatus(EventStatus status) {
case SCHEDULED -> unpublish();
case PUBLISHED -> publish();
case OPENED -> open();
case IN_PROGRESS -> inProgress();
case CANCELED -> cancel();
case FINISHED -> finish();
}
Expand Down Expand Up @@ -116,6 +117,18 @@ public void open() {
this.status = EventStatus.OPENED;
}

public void inProgress() {
if (this.status.isFinished())
throw new ChangeEventStatusException("Event is finished");
if (this.status.isCanceled())
throw new ChangeEventStatusException("Event is canceled");
if (this.status.isInProgress())
throw new ChangeEventStatusException("Event is already in progress");
if (this.status.isOpened())
this.status = EventStatus.IN_PROGRESS;
else throw new ChangeEventStatusException("Event needs to be open to get in progress");
}

public void publish() {
if (this.status.isFinished())
throw new ChangeEventStatusException("Event is finished");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ public enum EventStatus {
SCHEDULED(1, "Agendado"),
PUBLISHED(2, "Publicado"),
OPENED(3, "Aberto"),
CANCELED(4, "Cancelado"),
FINISHED(5, "Finalizado");
IN_PROGRESS(4, "Em andamento"),
CANCELED(5, "Cancelado"),
FINISHED(6, "Finalizado");

private final Integer code;
private final String description;
Expand Down Expand Up @@ -52,4 +53,9 @@ public boolean isFinished() {
public boolean isOpened() {
return this.equals(OPENED);
}

public boolean isInProgress() {
return this.equals(IN_PROGRESS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public void cancel() {
}

public void consume(Event event) {
if (!event.getStatus().isOpened())
throw new TicketConsumeException("Event is not opened");
if (!event.getStatus().isOpened() && !event.getStatus().isInProgress())
throw new TicketConsumeException("Event is not open and is not in progress");
if (!event.getId().equals(this.eventID))
throw new TicketConsumeException("Ticket does not belong to this event");
if (this.status.isCanceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h1 style="Margin:0;line-height:36px;mso-line-height-rule:exactly;font-family:ar
<p style="Margin:0;line-height:21px;mso-line-height-rule:exactly;font-family:arial, 'helvetica neue', helvetica, sans-serif;font-size:14px;color:#333333">
Prezado(a) {nome},<br><br>Obrigado por se inscrever
em nosso serviço. Estamos ansiosos para fornecer a
você a melhor experiência possível. Não esqueça de levar algum documento com foto!<br><br>Atenciosamente,<br>{company-name}
você a melhor experiência possível. Não esqueça de levar algum documento com foto!<br><br>Atenciosamente,<br>Grêmio Livre Estudantil "Chico Mendes"
</p>
</td>
</tr>
Expand Down

0 comments on commit 0524f6f

Please sign in to comment.