mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
for each selected, loop for post participation, then get response and commit state
This commit is contained in:
@@ -121,7 +121,7 @@ class AccompanyingCourseController extends Controller
|
||||
* @Route(
|
||||
* "/{_locale}/person/api/1.0/accompanying-course/{accompanying_period_id}/participation.{_format}",
|
||||
* name="chill_person_accompanying_course_api_add_participation",
|
||||
* methods={"POST"},
|
||||
* methods={"POST","DELETE"},
|
||||
* format="json",
|
||||
* requirements={
|
||||
* "_format": "json",
|
||||
@@ -129,7 +129,7 @@ class AccompanyingCourseController extends Controller
|
||||
* )
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
|
||||
*/
|
||||
public function addParticipationAPI(Request $request, AccompanyingPeriod $accompanyingCourse, $_format): Response
|
||||
public function participationAPI(Request $request, AccompanyingPeriod $accompanyingCourse, $_format): Response
|
||||
{
|
||||
switch ($_format) {
|
||||
case 'json':
|
||||
@@ -146,7 +146,9 @@ class AccompanyingCourseController extends Controller
|
||||
}
|
||||
|
||||
// TODO add acl
|
||||
$accompanyingCourse->addPerson($person);
|
||||
$participation = ($request->getMethod() === 'POST') ?
|
||||
$accompanyingCourse->addPerson($person) : $accompanyingCourse->removePerson($person);
|
||||
|
||||
$errors = $this->validator->validate($accompanyingCourse);
|
||||
|
||||
if ($errors->count() > 0) {
|
||||
@@ -156,6 +158,6 @@ class AccompanyingCourseController extends Controller
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
return new JsonResponse();
|
||||
return $this->json($participation);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user