Exemplo n.º 1
0
 public function addGroupAction(Request $request)
 {
     try {
         $em = $this->getDoctrine()->getManager();
         $data = json_decode($request->getContent());
         $educationForm = $em->getRepository('AppBundle:EducationForm')->find($data->educationForm);
         $group = new Group();
         $group->setCode($data->code);
         $group->setName($data->code);
         $group->setMail($data->mail);
         $group->setEducationForm($educationForm);
         $group->setStartYear($data->startYear);
         $em->persist($group);
         $em->flush();
         $response = ['success' => "Grupa a fost adaugata cu success"];
         return new JsonResponse($response);
     } catch (Exception $e) {
         $response = ['error' => "Au aparut careva probleme la adaugarea grupei. Va rugam incercati mai triziu!"];
         return new JsonResponse($response);
     }
 }