public function addorupdateclientAction() { try { if (!$this->authService->hasIdentity()) { throw new \Exception("Unauthorized Access"); } $jsonData = $this->getRequest()->getContent(); $client = $this->serializer->deserialize($jsonData, "Application\\API\\Canonicals\\Entity\\Client", "json"); $this->clientsRepository->addOrUpdateClient($client); $response = ResponseUtils::createWriteResponse($client); return $this->jsonResponse($response); } catch (\Exception $ex) { $response = ResponseUtils::createExceptionResponse($ex); return $this->jsonResponse($response); } }
public function updatequrbaniAction() { try { $authService = $this->getServiceLocator()->get('AdminAuthService'); if (!$authService->hasIdentity()) { throw new \Exception("Unauthorized Access"); } $jsonData = $this->getRequest()->getContent(); $data = $this->serializer->deserialize($jsonData, "Application\\API\\Canonicals\\Entity\\Qurbani", "json"); $qurbaniRepo = $this->getServiceLocator()->get('QurbaniRepo'); $donation = $qurbaniRepo->updateQurbani($data); $response = ResponseUtils::createWriteResponse($donation); return $this->jsonResponse($response); } catch (\Exception $ex) { $response = ResponseUtils::createExceptionResponse($ex); return $this->jsonResponse($response); } }
public function deleteuserAction() { try { $authService = $this->getServiceLocator()->get('AdminAuthService'); $jsonData = $this->getRequest()->getContent(); $data = $this->serializer->deserialize($jsonData, "Application\\API\\Canonicals\\Entity\\Users", "json"); if (!$authService->hasIdentity()) { throw new \Exception("Unauthorized Access"); } else { if ($authService->getIdentity() == $data->getUsername()) { throw new \Exception("Cannot Delete Current User"); } } $usersRepo = $this->getServiceLocator()->get('UsersRepo'); $usersRepo->deleteUser($data->getUsername(), $data->getPassword()); $response = ResponseUtils::createWriteResponse(array('users' => $usersRepo->findAll())); return $this->jsonResponse($response); } catch (\Exception $ex) { $response = ResponseUtils::createExceptionResponse($ex); return $this->jsonResponse($response); } }