diff --git a/src/LQDN/Command/CounterpartCreateCommand.php b/src/LQDN/Command/CounterpartCreateCommand.php index 2cfa70193b18bdc7a00fa75821ed0cce425fa073..1a0a7e3ba44884b09be4609b7926039532762751 100644 --- a/src/LQDN/Command/CounterpartCreateCommand.php +++ b/src/LQDN/Command/CounterpartCreateCommand.php @@ -12,7 +12,7 @@ class CounterpartCreateCommand private $status; private $date; - public function __construct($addressId, $userId, $quoi, $taille, $status, $date) + public function __construct($addressId, $userId, $quoi, $taille, $status, $date, $commentaire) { $this->userId = $userId; $this->addressId = $addressId; @@ -20,6 +20,7 @@ class CounterpartCreateCommand $this->taille = $taille; $this->status = $status; $this->date = $date; + $this->commentaire = $commentaire; } public function getUserId() @@ -51,4 +52,9 @@ class CounterpartCreateCommand { return $this->date; } + + public function getCommentaire() + { + return $this->commentaire; + } } diff --git a/src/LQDN/Command/UserUpdateCumulCommand.php b/src/LQDN/Command/UserUpdateCumulCommand.php new file mode 100644 index 0000000000000000000000000000000000000000..ced725fa90ee7226867b51ed78b7f77461c4b988 --- /dev/null +++ b/src/LQDN/Command/UserUpdateCumulCommand.php @@ -0,0 +1,25 @@ +<?php + +namespace LQDN\Command; + +class UserUpdateCumulCommand +{ + private $id; + private $cumul; + + public function __construct($id, $cumul) + { + $this->id = $id; + $this->cumul = $cumul; + } + + public function getId() + { + return $this->id; + } + + public function getCumul() + { + return $this->cumul; + } +} diff --git a/src/LQDN/Command/UserUpdateTotalCommand.php b/src/LQDN/Command/UserUpdateTotalCommand.php new file mode 100644 index 0000000000000000000000000000000000000000..dc098074edeec27f0fe372dc2959b20690aa9a94 --- /dev/null +++ b/src/LQDN/Command/UserUpdateTotalCommand.php @@ -0,0 +1,25 @@ +<?php + +namespace LQDN\Command; + +class UserUpdateTotalCommand +{ + private $id; + private $total; + + public function __construct($id, $total) + { + $this->id = $id; + $this->total = $total; + } + + public function getId() + { + return $this->id; + } + + public function getTotal() + { + return $this->total; + } +} diff --git a/src/LQDN/Handler/CounterpartHandler.php b/src/LQDN/Handler/CounterpartHandler.php index 6fdbce712ce17b263f295e9b46fbf3f1ac75f3cf..ef4b4af5812f3c83194bc22317880cda2d1a0009 100644 --- a/src/LQDN/Handler/CounterpartHandler.php +++ b/src/LQDN/Handler/CounterpartHandler.php @@ -43,8 +43,8 @@ class CounterpartHandler $adresseId = $command->getAddressId(); $query =<<<EOF -INSERT INTO contreparties(datec, user_id, adresse_id, quoi, taille, status) -VALUES (:datec, :user_id, :adresse_id, :quoi, :taille, :status) +INSERT INTO contreparties(datec, user_id, adresse_id, quoi, taille, status, commentaire) +VALUES (:datec, :user_id, :adresse_id, :quoi, :taille, :status, :commentaire) EOF; $stmt = $this->connection->prepare($query); $stmt->bindValue('datec', $command->getDateCreation()); @@ -53,6 +53,7 @@ EOF; $stmt->bindValue('quoi', $command->getQuoi()); $stmt->bindValue('taille', $command->getTaille()); $stmt->bindValue('status', $command->getStatus()); + $stmt->bindValue('commentaire', $command->getCommentaire()); $stmt->execute(); } diff --git a/src/LQDN/Handler/UserHandler.php b/src/LQDN/Handler/UserHandler.php index 5f13a683f304c038fa0b8830198bf7407403c8d2..4e886eff59d799c456f09898033ea915e5d7643b 100644 --- a/src/LQDN/Handler/UserHandler.php +++ b/src/LQDN/Handler/UserHandler.php @@ -4,6 +4,8 @@ namespace LQDN\Handler; use Doctrine\DBAL\Connection; use LQDN\Command\UserUpdateByAdminCommand; +use LQDN\Command\UserUpdateTotalCommand; +use LQDN\Command\UserUpdateCumulCommand; class UserHandler { @@ -28,4 +30,36 @@ class UserHandler 'id' => $command->getId(), ]); } + + /** + * Update the user total + * + * @param UserUpdateTotalCommand $command + */ + public function handleUserUpdateTotalCommand(UserUpdateTotalCommand $command) + { + $this->connection->executeUpdate( + 'UPDATE users SET total = :total WHERE id = :id', + [ + 'total' => $command->getTotal(), + 'id'=> $command->getId() + ] + ); + } + + /** + * Update the user cumul + * + * @param UserUpdateCumulCommand $command + */ + public function handleUserUpdateCumulCommand(UserUpdateCumulCommand $command) + { + $this->connection->executeUpdate( + 'UPDATE users SET cumul = :cumul WHERE id = :id', + [ + 'cumul' => $command->getCumul(), + 'id' => $command->getId(), + ] + ); + } }