| Conditions | 3 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public function castVoteAction() |
||
| 14 | { |
||
| 15 | $userData = json_decode(file_get_contents('php://input')); |
||
| 16 | |||
| 17 | $userModel = new UserModel(new Database()); |
||
| 18 | |||
| 19 | if($userModel->loadUserByEmail($userData->email)) { |
||
| 20 | return ApiResponse::error('USER_EXISTS'); |
||
| 21 | } |
||
| 22 | |||
| 23 | try { |
||
| 24 | $userModel->saveUser($userData->email, $userData->first_name, $userData->surname, $userData->constituency, $userData->voting, $userData->candidate); |
||
| 25 | |||
| 26 | return ApiResponse::success('DEFAULT_RESPONSE_SUCCESS'); |
||
| 27 | } catch(\Exception $e) { |
||
| 28 | return ApiResponse::error('USER_SAVE_FAIL'); |
||
| 29 | } |
||
| 30 | } |
||
| 31 | } |