nc-vue-agency/lib/Controller/AgencyController.php

79 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\Agency\Controller;
use OCP\IRequest;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Controller;
use OCA\Agency\Service\AgencyService;
class AgencyController extends Controller {
private $service;
private $Id;
use Errors;
public function __construct(string $AppName, IRequest $request,
AgencyService $service){
parent::__construct($AppName, $request);
$this->service = $service;
}
/**
* @NoAdminRequired
*/
public function index() {
return new DataResponse($this->service->findAll($this->Id));
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* @param int $id
*/
public function show(int $id) {
return $this->handleNotFound(function () use ($id) {
return $this->service->find($id);
});
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $title
* @param string $content
*/
public function create(string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
return $this->service->create($name, $inhaber, $street, $plz, $city, $agencymail, $phone);
}
/**
* @NoAdminRequired
* @NoCSRFRequired
*
* @param int $id
* @param string $title
*/
public function update(int $id, string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
return $this->handleNotFound(function () use ($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone) {
return $this->service->update($id, $name, $inhaber, $street, $plz, $city, $agencymail, $phone);
});
}
/**
* @NoAdminRequired
*
* @param int $id
*/
public function destroy(int $id) {
return $this->handleNotFound(function () use ($id) {
return $this->service->delete($id);
});
}
}