Example #1
0
 public function post(\Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Vote command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'save':
             $json = Factory::post($this->student);
             break;
         default:
             throw new \Exception('Unknown Vote command');
     }
     $view = new \View\JsonView($json);
     $response = new \Response($view);
     return $response;
 }
Example #2
0
 public function post(\Request $request)
 {
     if (!$request->isVar('command')) {
         throw new \Exception('Unknown Election command');
     }
     $command = $request->getVar('command');
     switch ($command) {
         case 'save':
             Factory::post();
             break;
         case 'delete':
             if (\Current_User::isDeity()) {
                 Factory::delete(Factory::pullPostInteger('electionId'));
             } else {
                 throw new \Exception('Non-deity election deletion not allowed.');
             }
             break;
         case 'saveTitle':
             $this->saveTitle();
             break;
         case 'saveDates':
             $this->saveDates();
             break;
         case 'resetVote':
             \election\Factory\Vote::resetVote(Factory::pullPostInteger('electionId'), Factory::pullPostInteger('bannerId'));
             break;
         default:
             throw new \Exception('Unknown Election command');
     }
     $view = new \View\JsonView(array('success' => true));
     $response = new \Response($view);
     return $response;
 }