Commit 77495ef5 authored by Zohten's avatar Zohten

added a way to update actions

parent 9911b38f
......@@ -36,6 +36,16 @@ class RoundController extends Controller
$body = $this->request->getData();
return $this->newRound($body);
break;
case 'PUT':
// If there is a uriParams, it is the /round/{id}/action endpoint
if ($uriParams) {
$lenUriParams = count($uriParams);
if (($lenUriParams == 2) && ($uriParams[1]=='action')) {
$body = $this->request->getData();
return $this->updateActions(array_merge($body, ['id'=>$uriParams[0]]));
}
}
break;
}
$message = json_encode(["message" => "unsupported parameters or method in round"]);
return Response::errorResponse($message);
......@@ -91,5 +101,18 @@ class RoundController extends Controller
return $response;
}
/**
* (PUT) Add action of the round in Round table
*
* @param string $action string containing all actions
* @return Response
*/
protected function updateActions($action)
{
//print_r($action); die('bite');
Round::updateActions($action);
$message = json_encode(["message" => 'Actions updated!']);
$response = Response::createdResponse($message);
return $response;
}
}
\ No newline at end of file
......@@ -34,4 +34,9 @@ class Round extends Model
$stm = parent::exec('ROUND_CREATE', $pimped_array);
}
public static function updateActions($array)
{
$stm = parent::exec('ACTION_UPDATE', $array);
}
}
\ No newline at end of file
......@@ -27,8 +27,14 @@ Game::addSqlQuery(
WHERE r.ID_ROUND=:id'
);
User::addSqlQuery(
Game::addSqlQuery(
'ROUND_CREATE',
'INSERT INTO MJ_ROUND (ID_ROUND ,ID_GAME ,PREVAILING_WIND ,SEED ,BEGINING ,ENDING ,ACTIONS)
VALUES (NULL, :id_game, :prevailing_wind, :seed, :begin_date, NULL, NULL)'
);
Game::addSqlQuery(
'ACTION_UPDATE',
'UPDATE MJ_ROUND
SET ACTIONS = :actions WHERE ID_ROUND = :id'
);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment