Error handling for undoDelete and created an update method in BoardApiController
Signed-off-by: Ryan Fletcher <ryan.fletcher@codepassion.ca>
This commit is contained in:
committed by
Julius Härtl
parent
3b49c7f262
commit
d82746be97
@@ -3,6 +3,7 @@
|
||||
* @copyright Copyright (c) 2017 Steven R. Baker <steven@stevenrbaker.com>
|
||||
*
|
||||
* @author Steven R. Baker <steven@stevenrbaker.com>
|
||||
* @author Ryan Fletcher <ryan.fletcher@codepassion.ca>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
@@ -101,6 +102,28 @@ class BoardApiController extends ApiController {
|
||||
return new DataResponse($board);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @CORS
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* @params $boardId
|
||||
* @params $title
|
||||
* @params $color
|
||||
* @params $archived
|
||||
*
|
||||
* Create a board with the specified title and color.
|
||||
*/
|
||||
public function update($boardId, $title, $color, $archived) {
|
||||
$board = $this->service->update($boardId, $title, $color, $archived);
|
||||
|
||||
if ($board === false || $board === null) {
|
||||
return new DataResponse('Board not found', HTTP::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
return new DataResponse($board, HTTP::STATUS_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @CORS
|
||||
@@ -131,9 +154,14 @@ class BoardApiController extends ApiController {
|
||||
*/
|
||||
public function undoDelete($id) {
|
||||
$board = $this->service->find($id);
|
||||
$this->service->deleteUndo($id);
|
||||
|
||||
return new DataResponse($board);
|
||||
if ($board === false || $board === null) {
|
||||
return new DataResponse('Board not found', HTTP::STATUS_NOT_FOUND);
|
||||
} else {
|
||||
$board = $this->service->deleteUndo($id);
|
||||
}
|
||||
|
||||
return new DataResponse($board, HTTP::STATUS_OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user