diff --git a/lib/Controller/AgencyController.php b/lib/Controller/AgencyController.php
index fa1c459..99bb223 100644
--- a/lib/Controller/AgencyController.php
+++ b/lib/Controller/AgencyController.php
@@ -31,6 +31,7 @@ class AgencyController extends Controller {
/**
* @NoAdminRequired
+ * @NoCSRFRequired
*
* @param int $id
*/
@@ -47,19 +48,20 @@ class AgencyController extends Controller {
* @param string $title
* @param string $content
*/
- public function create(string $name) {
- return $this->service->create($name);
+ 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) {
- return $this->handleNotFound(function () use ($id, $name) {
- return $this->service->update($id, $name);
+ 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);
});
}
diff --git a/lib/Db/Agency.php b/lib/Db/Agency.php
index 0114048..877ccbd 100644
--- a/lib/Db/Agency.php
+++ b/lib/Db/Agency.php
@@ -8,6 +8,12 @@ use OCP\AppFramework\Db\Entity;
class Agency extends Entity implements JsonSerializable {
protected $name;
+ protected $inhaber;
+ protected $street;
+ protected $plz;
+ protected $city;
+ protected $agencymail;
+ protected $phone;
public function __construct() {
$this->addType('id','integer');
@@ -16,7 +22,13 @@ class Agency extends Entity implements JsonSerializable {
public function jsonSerialize() {
return [
'id' => $this->id,
- 'name' => $this->title,
+ 'name' => $this->name,
+ 'inhaber' => $this->inhaber,
+ 'street' => $this->street,
+ 'plz' => $this->plz,
+ 'city' => $this->city,
+ 'agencymail' => $this->agencymail,
+ 'phone' => $this->phone,
];
}
}
\ No newline at end of file
diff --git a/lib/Db/AgencyMapper.php b/lib/Db/AgencyMapper.php
index 7c8bc83..3f866ad 100644
--- a/lib/Db/AgencyMapper.php
+++ b/lib/Db/AgencyMapper.php
@@ -7,7 +7,7 @@ use OCP\AppFramework\Db\QBMapper;
class AgencyMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'agencys', Note::class);
+ parent::__construct($db, 'agencys', Agency::class);
}
public function find(int $id) {
diff --git a/lib/Migration/Version000001Date20210521125400.php b/lib/Migration/Version000001Date20210521125400.php
index 3cc2f3d..f741e62 100644
--- a/lib/Migration/Version000001Date20210521125400.php
+++ b/lib/Migration/Version000001Date20210521125400.php
@@ -21,6 +21,7 @@
if (!$schema->hasTable('agencys')) {
$table = $schema->createTable('agencys');
+
$table->addColumn('id', 'integer', [
'autoincrement' => true,
'notnull' => true,
@@ -50,7 +51,7 @@
'length' => 5
]);
- $table->addColumn('agency_email', 'string', [
+ $table->addColumn('agencymail', 'string', [
'notnull' => false,
'length' => 200
]);
@@ -71,12 +72,12 @@
'notnull' => true,
]);
- $table->rColumn('agency', 'integer', [
+ $table->addColumn('agency', 'integer', [
'notnull' => true,
'length' => 64
]);
- $table->rColumn('user', 'integer', [
+ $table->addColumn('user', 'integer', [
'notnull' => true,
'length' => 64
]);
diff --git a/lib/Service/AgencyService.php b/lib/Service/AgencyService.php
index 87902ff..9171941 100644
--- a/lib/Service/AgencyService.php
+++ b/lib/Service/AgencyService.php
@@ -27,6 +27,7 @@ class AgencyService {
}
}
+ //Find an Agency
public function find(int $id) {
try {
return $this->mapper->find($id);
@@ -35,10 +36,33 @@ class AgencyService {
}
}
- public function create(string $name) {
+ //Create an Agency
+ public function create(string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
$agency = new Agency();
$agency->setName($name);
+ $agency->setInhaber($inhaber);
+ $agency->setStreet($street);
+ $agency->setPlz($plz);
+ $agency->setCity($city);
+ $agency->setAgencymail($agencymail);
+ $agency->setPhone($phone);
return $this->mapper->insert($agency);
}
+ //Update an Agency
+ public function update(int $id, string $name, string $inhaber, string $street, string $plz, string $city, string $agencymail, string $phone) {
+ try {
+ $agency = $this->mapper->find($id);
+ } catch(Exception $e) {
+ return new DataResponse([], Http::STATUS_NOT_FOUND);
+ }
+ $agency->setName($name);
+ $agency->setInhaber($inhaber);
+ $agency->setStreet($street);
+ $agency->setPlz($plz);
+ $agency->setCity($city);
+ $agency->setAgencymail($agencymail);
+ $agency->setPhone($phone);
+ return $this->mapper->update($agency);
+ }
}
\ No newline at end of file
diff --git a/src/views/AgencyData.vue b/src/views/AgencyData.vue
index 8e33e4d..1517fa8 100644
--- a/src/views/AgencyData.vue
+++ b/src/views/AgencyData.vue
@@ -1,18 +1,81 @@
-
-
-
-
+
+ Agenturdaten
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+