Beispiel #1
0
 /**
  * Recebe um parametro no formato:
  * deleteContato?id=valor
  */
 private function deleteContato()
 {
     if ($this->get_request_method() !== 'DELETE') {
         $this->response('', API::STATUS_NOT_ACCEPTABLE);
     }
     $idContato = (int) $this->_request['id'];
     if ($idContato > 0) {
         $objeto = DBManual::getContatoByID($idContato);
         if (!is_null($objeto)) {
             if (DBObject::deleteContato($objeto)) {
                 $success = array('status' => 'Sucesso', 'msg' => 'Contato deletado com sucesso.');
                 $this->response($this->json($success), API::STATUS_OK);
             } else {
                 $this->response('', API::STATUS_NO_CONTENT);
             }
         } else {
             $this->response('', API::STATUS_NOT_FOUND);
         }
     } else {
         $this->response('', API::STATUS_NO_CONTENT);
     }
 }
Beispiel #2
0
 public static function updateEmail($objeto)
 {
     $objetoTrabalho = parent::getEntityManager()->find(DBObject::TABLE_EMAIL, $objeto->getId());
     if (!is_null($objetoTrabalho)) {
         if (!is_null($objeto->getEndereco())) {
             $objetoTrabalho->setEndereco($objeto->getEndereco());
         }
         if (!is_null($objeto->getContato()->getId())) {
             $contato = DBManual::getContatoByID($objeto->getContato()->getId());
             $objetoTrabalho->setContato($contato);
         }
         parent::getEntityManager()->persist($objetoTrabalho);
         if (parent::checkEntityState($objetoTrabalho, UnitOfWork::STATE_MANAGED)) {
             parent::getEntityManager()->flush();
             return $objetoTrabalho;
         }
     }
     return null;
 }