public function postReservationsAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $entity = new Reservation();
     $entity->setDatetime(new \Datetime('now'));
     $entity->setCourt($em->getRepository('AppBundle:Court')->find($request->query->get('courtid')));
     $entity->setUser($em->getRepository('AppBundle:User')->find($request->query->get('userid')));
     $em->persist($entity);
     $em->flush();
 }
Exemplo n.º 2
0
 public function createAction($format)
 {
     try {
         $em = $this->getDoctrine()->getManager();
         $reservation = new Reservation();
         $params = array();
         $content = $this->get("request")->getContent();
         if (!empty($content)) {
             $params = json_decode($content, true);
             var_dump($params);
             $reservation->setCourt($params['court']);
             $reservation->setDatetime(new \DateTime($params['datetime']));
             $reservation->setUser($params['user']);
         }
         $em->persist($reservation);
         $em->flush();
         return $this->formatResponse("ok", $format);
     } catch (Exception $ex) {
         return $this->formatResponse("error", $format);
     }
 }