Editar propiedad en venta
This commit is contained in:
@ -7,12 +7,30 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use Incoviba\Controller\API\{withJson, emptyBody};
|
||||
use Incoviba\Controller\withRedis;
|
||||
use Incoviba\Common\Implement\Exception\{EmptyResult,EmptyRedis};
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class PropiedadesUnidades
|
||||
{
|
||||
use emptyBody, withJson, withRedis;
|
||||
|
||||
public function add(ServerRequestInterface $request, ResponseInterface $response, Service\Venta\PropiedadUnidad $propiedadUnidadService): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'input' => $body,
|
||||
'propiedad_unidad' => null,
|
||||
'added' => false
|
||||
];
|
||||
try {
|
||||
$pu = $propiedadUnidadService->add($body);
|
||||
$output['propiedad_unidad'] = $pu;
|
||||
$output['added'] = true;
|
||||
} catch (EmptyResult $exception) {
|
||||
error_log($exception);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta\PropiedadUnidad $propiedadUnidadService, int $pu_id): ResponseInterface
|
||||
{
|
||||
@ -29,4 +47,18 @@ class PropiedadesUnidades
|
||||
} catch (PDOException | EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function remove(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Venta\PropiedadUnidad $propiedadUnidadRepository, int $pu_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'propiedad_unidad_id' => $pu_id,
|
||||
'removed' => false
|
||||
];
|
||||
try {
|
||||
$pu = $propiedadUnidadRepository->fetchById($pu_id);
|
||||
$propiedadUnidadRepository->remove($pu);
|
||||
$output['removed'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user