Ejemplo n.º 1
0
 /**
  * Creates a new trainers entity.
  * @Secure(roles="ROLE_SUPER_USER,ROLE_RECORDTRAINING_CREATE")
  * @Route("/add_to_instance", name="trainer_add_to_event")
  * @Method("GET|POST")
  *
  */
 public function addToeventAction(Request $request)
 {
     /// querying instance record table to see existing record instance pairs//
     $instance_id = $this->getRequest()->get('instance_id');
     $trainer_id = $this->getRequest()->get('trainer_id');
     $entity = new instanceTrainer();
     //
     //
     $entity->setInstanceId($instance_id);
     $entity->setTrainerId($trainer_id);
     //
     $em = $this->getDoctrine()->getManager();
     $em->persist($entity);
     $em->flush();
     //
     return new Response("success");
 }
 /**
  * @Route("/addtrainers",name="addtrainers")
  * @Method("POST")
  *
  */
 public function addtrainersAction(Request $request)
 {
     $response = "success";
     $ary = $request->request->get("ary");
     $instance_id = $request->request->get("instance_id");
     $trainerIds = explode(',', $ary);
     try {
         foreach ($trainerIds as $trainerId) {
             $instaTra = new instanceTrainer();
             $instaTra->setTrainerId($trainerId);
             $instaTra->setInstanceId($instance_id);
             $em = $this->getDoctrine()->getManager();
             $em->persist($instaTra);
             $em->flush();
         }
     } catch (\Exception $e) {
         $response = "failure";
     }
     return new Response($response);
 }