public function bookAction()
 {
     $variables = array();
     $config = $this->getServiceLocator()->get('Config');
     $query = $this->getServiceLocator()->get('wrapperQuery')->setEntity('Courses\\Entity\\Course');
     $options['query'] = $query;
     $examBook = new \Courses\Entity\ExamBook();
     $examModel = $this->getServiceLocator()->get('Courses\\Model\\Exam');
     $validationResult = $this->getServiceLocator()->get('aclValidator')->validateOrganizationAccessControl($this->getResponse(), Role::TEST_CENTER_ADMIN_ROLE);
     if ($validationResult["isValid"] === false && !empty($validationResult["redirectUrl"])) {
         return $this->redirect()->toUrl($validationResult["redirectUrl"]);
     }
     $auth = new AuthenticationService();
     $storage = $auth->getIdentity();
     //checking if user is admin or test center admin
     if ($auth->hasIdentity()) {
         if (!(in_array(Role::ADMIN_ROLE, $storage['roles']) || in_array(Role::TEST_CENTER_ADMIN_ROLE, $storage['roles']))) {
             $this->getResponse()->setStatusCode(302);
             $url = $this->getEvent()->getRouter()->assemble(array(), array('name' => 'noaccess'));
             $this->redirect()->toUrl($url);
         }
     }
     $form = new \Courses\Form\BookExam(null, $options);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $data = $request->getPost()->toArray();
         $form->setInputFilter($examBook->getInputFilter());
         $form->setData($data);
         if ($form->isValid()) {
             // save exam rquest
             $examModel->saveBookingRequest($data, $config);
             //              // redirect
             $url = $this->getEvent()->getRouter()->assemble(array('action' => 'calendar'), array('name' => "coursesCalendar"));
             $this->redirect()->toUrl($url);
         }
     }
     $variables['bookExamForm'] = $this->getFormView($form);
     return new ViewModel($variables);
 }