diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/VolunteerApplication.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/VolunteerApplication.kt index 7a663fe54..6510a920a 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/VolunteerApplication.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/model/VolunteerApplication.kt @@ -16,13 +16,13 @@ data class VolunteerApplication( val approved: Boolean, ) { - fun checkCancelable(approved: Boolean) { + fun checkIsNotApproved() { if (approved) { throw VolunteerApplicationAlreadyAssigned } } - fun checkExcludable(approved: Boolean) { + fun checkIsApproved() { if (!approved) { throw VolunteerApplicationNotAssigned } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApproveVolunteerApplicationUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApproveVolunteerApplicationUseCase.kt index 3e1d828ea..34aaf6be4 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApproveVolunteerApplicationUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ApproveVolunteerApplicationUseCase.kt @@ -13,6 +13,8 @@ class ApproveVolunteerApplicationUseCase( val currentVolunteerApplication = volunteerService.getVolunteerApplicationById(volunteerApplicationId) + currentVolunteerApplication.checkIsNotApproved() + volunteerService.saveVolunteerApplication( currentVolunteerApplication.copy( approved = true diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ExcludeVolunteerApplicationUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ExcludeVolunteerApplicationUseCase.kt index 6370333f4..e909bed84 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ExcludeVolunteerApplicationUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/ExcludeVolunteerApplicationUseCase.kt @@ -12,9 +12,7 @@ class ExcludeVolunteerApplicationUseCase( fun execute(volunteerApplicationId: UUID) { val currentVolunteerApplication = volunteerService.getVolunteerApplicationById(volunteerApplicationId) - currentVolunteerApplication.apply { - checkExcludable(currentVolunteerApplication.approved) - } + currentVolunteerApplication.checkIsApproved() volunteerService.deleteVolunteerApplication(currentVolunteerApplication) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/RejectVolunteerApplicationUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/RejectVolunteerApplicationUseCase.kt index dfe8b2412..a8a686c24 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/RejectVolunteerApplicationUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/RejectVolunteerApplicationUseCase.kt @@ -12,9 +12,7 @@ class RejectVolunteerApplicationUseCase( fun execute(volunteerApplicationId: UUID) { val currentVolunteerApplication = volunteerService.getVolunteerApplicationById(volunteerApplicationId) - currentVolunteerApplication.apply { - checkCancelable(currentVolunteerApplication.approved) - } + currentVolunteerApplication.checkIsNotApproved() volunteerService.deleteVolunteerApplication(currentVolunteerApplication) } diff --git a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UnapplyVolunteerUseCase.kt b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UnapplyVolunteerUseCase.kt index 2709be996..9a2513da3 100644 --- a/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UnapplyVolunteerUseCase.kt +++ b/dms-core/src/main/kotlin/team/aliens/dms/domain/volunteer/usecase/UnapplyVolunteerUseCase.kt @@ -12,10 +12,7 @@ class UnapplyVolunteerUseCase( fun execute(volunteerApplicationId: UUID) { val volunteer = volunteerService.getVolunteerApplicationById(volunteerApplicationId) - volunteerService.getVolunteerApplicationById(volunteerApplicationId) - .apply { - checkCancelable(volunteer.approved) - } + volunteer.checkIsNotApproved() volunteerService.deleteVolunteerApplication(volunteer) }