Commit 84a543f6 authored by okhin's avatar okhin 🚴

Adding user handling command for total and cumul

parent 51d8b106
......@@ -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;
}
}
<?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;
}
}
<?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;
}
}
......@@ -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();
}
......
......@@ -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(),
]
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment