Fixed issue related to creating multiple applications per user based on their company
This commit is contained in:
@@ -560,15 +560,15 @@ public class ApplicationDao {
|
||||
ApplicationRequest applicationRequest, Long callId, UserEntity userEntity) {
|
||||
CallEntity call = callService.validateCall(callId);
|
||||
// call = callService.validatePublishedCall(call.getId());
|
||||
checkIfApplicationExists(call, companyEntity);
|
||||
checkIfApplicationExists(call, companyEntity, userEntity);
|
||||
ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, companyEntity);
|
||||
applicationEntity.setComments(applicationRequest.getComments());
|
||||
applicationEntity = saveApplicationEntity(applicationEntity);
|
||||
ApplicationResponse applicationResponse = getApplicationResponse(applicationEntity);
|
||||
return applicationResponse;
|
||||
}
|
||||
public void checkIfApplicationExists(CallEntity call, CompanyEntity companyEntity){
|
||||
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByCompanyIdAndCallIdAndIsDeletedFalse(companyEntity.getId(),call.getId());
|
||||
public void checkIfApplicationExists(CallEntity call, CompanyEntity companyEntity, UserEntity userEntity){
|
||||
Optional<ApplicationEntity> applicationEntity=applicationRepository.findByUserIdAndCompanyIdAndCallIdAndIsDeletedFalse(userEntity.getId(), companyEntity.getId(),call.getId());
|
||||
if(applicationEntity.isPresent()){
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_EXISTS));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user