public static function parse($record) { if ($record == null) { return null; } $instituto = new Instituto(); $instituto->setId($record["idInstituto"]); $instituto->setNome($record["Nome"]); return $instituto; }
require '../persistencia/instituto/InstitutoService.php'; $tiporequest = $_SERVER['REQUEST_METHOD']; if ($tiporequest == "GET") { InstitutoView::exibeInstitutos(); } else { if ($tiporequest == "POST") { $funcao = $_POST['funcao']; if ($funcao == "deletar") { $idinst = $_POST['idinst']; $institutodeletar = InstitutoService::getById($idinst); InstitutoService::delete($institutodeletar); } else { if ($funcao == "criar") { $nomeinst = $_POST['nomeinst']; $institutocriar = new Instituto(); $institutocriar->setNome(utf8_encode($nomeinst)); $criou = InstitutoService::inserir($institutocriar); if (!is_null($criou)) { $institutocriado = InstitutoService::getByNome($nomeinst); $arrayretorno['nomeinst'] = $nomeinst; $arrayretorno['idinst'] = $institutocriado->getId(); $retornoJSON = json_encode($arrayretorno); echo $retornoJSON; } else { $retornoJSON = json_encode(NULL); echo $retornoJSON; } } else { if ($funcao == "atualizar") { $novonome = $_POST['novonome']; $idinst = $_POST['idinst'];