Skip to content

Commit

Permalink
fix: impossible to edit an event in some conditions #49
Browse files Browse the repository at this point in the history
  • Loading branch information
bayang committed Oct 24, 2022
1 parent 1d2edd9 commit cfa0ad1
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,22 @@ class ReadingEventRepository {
}

fun updateReadingEvent(readingEventId: UUID, updateReadingEventDto: UpdateReadingEventDto): ReadingEvent {
val entity = ReadingEvent[readingEventId]
if (updateReadingEventDto.startDate != null &&
updateReadingEventDto.eventDate != null &&
updateReadingEventDto.eventDate.isBefore(updateReadingEventDto.startDate)
) {
throw JeluException("start date cannot be after event date")
}
val entity = ReadingEvent[readingEventId]
if (updateReadingEventDto.eventDate != null && updateReadingEventDto.eventDate.isBefore(entity.startDate)) {
} else if (updateReadingEventDto.eventDate != null &&
updateReadingEventDto.startDate == null &&
updateReadingEventDto.eventDate.isBefore(entity.startDate)
) {
throw JeluException("event date cannot be before start date")
}
if (updateReadingEventDto.startDate != null && entity.endDate != null && updateReadingEventDto.startDate.isAfter(entity.endDate)) {
} else if (updateReadingEventDto.startDate != null &&
entity.endDate != null &&
updateReadingEventDto.eventDate == null &&
updateReadingEventDto.startDate.isAfter(entity.endDate)
) {
throw JeluException("start date cannot be after end date")
}
return entity.apply {
Expand Down

0 comments on commit cfa0ad1

Please sign in to comment.