Last active
February 23, 2021 21:26
-
-
Save bion/ec9d9f663aeb6b46d95c70ee2a86d158 to your computer and use it in GitHub Desktop.
applicant system controller sketches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicantProgramBlocksController { | |
// GET /applicants/22/programs/12/block/21/edit | |
public CompletionStage<Response> edit(long applicantId, long programId, long blockId) { | |
return applicantService.getReadOnlyApplicantService(applicantId, programId) | |
.then((ReadOnlyApplicantService roApplicantService) -> { | |
ImmutableList<Block> blockList = roApplicantService.getCurrentBlockList(); | |
return ok(views.html.blockForm.render(blockList, blockId)); | |
}); | |
} | |
// PATCH or PUT /applicants/22/programs/12/block/21 | |
public CompletionStage<Response> update(long applicantId, long programId, long blockId, Form formData) { | |
ImmutableList<Update> updates = getUpdates(formData); | |
return applicantService | |
.update(applicantId, updates, programId) | |
.then((ErrorAnd<ReadOnlyApplicantService> errorAnd) -> { | |
ReadOnlyApplicantService roApplicantService = errorAnd.getWrapped(); | |
if (errorAnd.isError()) { | |
ImmutableList<Block> blockList = roApplicantService.getCurrentBlockList(); | |
return badRequest(views.html.blockForm.render( | |
blockList, | |
blockId, | |
updates, | |
errorAnd.getErrors())); | |
} else { | |
Block nextBlock = roApplicantService.getBlockAfter(blockId); | |
return redirect(controllers.routes.ApplicantProgramBlocksController.edit(programId, nextBlock.id())); | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicantProgramsController { | |
public CompletionStage<Response> index(long applicantId) { | |
return programService.getAllThePrograms().then(programList -> { | |
return ok(controllers.ApplicantProgramsController.index(programList)); | |
}); | |
} | |
// GET /applicants/22/programs/12/edit | |
public CompletionStage<Response> edit(long applicantId, long programId) { | |
return applicantService.getReadOnlyApplicantService(applicantId, programId) | |
.then((ReadOnlyApplicantService roApplicantService) -> { | |
Block firstBlock = roApplicantService.getFirstIncompleteBlock(); | |
return redirect(controllers.routes.ApplicantProgramBlocksController.edit(programId, firstBlock)); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment