public function removeEventNgAction($event_id)
 {
     $em = $this->getDoctrine()->getManager();
     $response = new Response(json_encode(array("result" => Event::removeEventById($em, $event_id))));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
 public static function addEvent($em, $parameters)
 {
     $event = new Event();
     $user = $em->getRepository("RenovateMainBundle:User")->find($parameters->userId);
     $project = $em->getRepository("RenovateMainBundle:Project")->find($parameters->projectId);
     $event->setUserId($user->getId());
     $event->setUser($user);
     $event->setProjectId($project->getId());
     $event->setProject($project);
     $event->setTitle($user->getSurname() . ' ' . mb_substr($user->getName(), 0, 1, 'UTF-8') . '. ' . mb_substr($user->getPatronymic(), 0, 1, 'UTF-8') . '. | ' . $project->getName());
     $start = new \DateTime($parameters->start);
     $end = new \DateTime($parameters->end);
     if ($start > $end) {
         return false;
     }
     $event->setStart($start);
     $event->setEnd($end);
     $em->persist($event);
     $em->flush();
     return $event;
 }