Checkpoints: WORKS but not for all

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2021-01-06 16:50:08 +01:00
parent df7701ebc8
commit b633d2c2df
3 changed files with 24 additions and 3 deletions

View File

@ -68,13 +68,17 @@ public class ExchangeController extends TokenBasedController{
}
final Assignment assignmentInstance = assignment.get();
final Groups groupInstance = group.get();
final Optional<Exchange> exchangeInstance = this.exchangeService.checkForExchange(assignmentInstance, groupInstance);
if(!(assignmentInstance.getCommision().getCommisionOwner().getId() == asker.getId() && assignmentInstance.isAccepted())){
return new ResponseEntity<>("Some of problems appeared. Check if you have access to given assignment and if it is accepted", HttpStatus.BAD_REQUEST);
if(!(assignmentInstance.getCommision().getCommisionOwner().getId() == asker.getId() && assignmentInstance.isAccepted() && exchangeInstance.isEmpty())){
return new ResponseEntity<>("Some of problems appeared. Check if you have access to given assignment and if it is accepted or the exchange has not been already added.", HttpStatus.BAD_REQUEST);
}
this.exchangeService.save(new Exchange(assignment.get(), group.get()));
this.exchangeService.save(new Exchange(assignmentInstance, groupInstance));
return new ResponseEntity<>("Success", HttpStatus.OK);
}
}