Updated the CardApiController->update method to allow updating of archive state and assigned user,.

Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
Ryan Fletcher
2018-07-13 10:52:14 -04:00
committed by Julius Härtl
parent b82591a0bc
commit 7e4d24236a

View File

@@ -129,10 +129,12 @@ class CardApiController extends ApiController {
* @params $order * @params $order
* @params $description * @params $description
* @params $duedate * @params $duedate
* @params $archive
* @params $assignedUserId
* *
* Get a specific card. * Get a specific card.
*/ */
public function update($title, $type, $order, $description = null, $duedate = null) { public function update($title, $type, $order, $description = null, $duedate = null, $archive = false, $assignedUserId = 0) {
if (is_numeric($this->request->params['cardId']) === false) { if (is_numeric($this->request->params['cardId']) === false) {
return new DataResponse("card id must be a number", HTTP::STATUS_BAD_REQUEST); return new DataResponse("card id must be a number", HTTP::STATUS_BAD_REQUEST);
@@ -154,6 +156,14 @@ class CardApiController extends ApiController {
return new DataResponse("order must be a number", HTTP::STATUS_BAD_REQUEST); return new DataResponse("order must be a number", HTTP::STATUS_BAD_REQUEST);
} }
if (is_bool($order) === false) {
return new DataResponse("archive must be a boolean", HTTP::STATUS_BAD_REQUEST);
}
if (is_numeric($assignedUserId) === false) {
return new DataResponse("user id must be a number", HTTP::STATUS_BAD_REQUEST);
}
try { try {
$card = $this->cardService->update( $card = $this->cardService->update(
$this->request->params['cardId'], $this->request->params['cardId'],
@@ -164,6 +174,19 @@ class CardApiController extends ApiController {
$description, $description,
$this->userId, $this->userId,
$duedate); $duedate);
if ($archive) {
$card = $this->cardService->archive($this->request->params['cardId']);
} else {
$card = $this->cardService->unarchive($this->request->params['cardId']);
}
if ($assignedUserId > 0) {
$card = $this->cardService->assignUser($this->request->params['cardId'], $assignedUserId);
} else {
$card = $this->cardService->assignUser($this->request->params['cardId'], $assignedUserId);
}
} catch(Exception $e) { } catch(Exception $e) {
return new DataResponse($e->getMessage(), HTTP::STATUS_INTERNAL_SERVER_ERROR); return new DataResponse($e->getMessage(), HTTP::STATUS_INTERNAL_SERVER_ERROR);
} }