public function service()
 {
     $serviceCompanyDealersManager = new ServiceCompanyDealersManager($this->config, $this->args);
     $userId = $serviceCompanyDealersManager->secure($_REQUEST["user_id"]);
     $serviceCompanyId = $this->sessionManager->getUser()->getId();
     if ($serviceCompanyDealersManager->getByCompanyIdAndUserId($userId, $serviceCompanyId)) {
         $serviceCompanyDealersManager->removeUserFromCompany($userId, $serviceCompanyId);
         $jsonArr = array('status' => "ok", "message" => "Dealer successfully removed from your company!");
         echo json_encode($jsonArr);
         return true;
     } else {
         $jsonArr = array('status' => "err", "errText" => "System Error: Dealer dosn't exist in your list!");
         echo json_encode($jsonArr);
         return false;
     }
 }
 public function service()
 {
     $serviceCompanyManager = new ServiceCompanyManager($this->config, $this->args);
     $serviceCompanyDealersManager = new ServiceCompanyDealersManager($this->config, $this->args);
     $access_key = $this->secure($_REQUEST["access_key"]);
     $service_company_id = $this->secure($_REQUEST["service_company_id"]);
     $serviceCompany = $serviceCompanyManager->selectByPK($service_company_id);
     if (!isset($serviceCompany)) {
         $this->error(array("errText" => "System error! Company doesn't exists."));
     }
     if (strcasecmp($access_key, $serviceCompany->getAccessKey()) != 0) {
         $this->error(array("errText" => "Wrong access key!"));
     }
     $userId = $this->getUserId();
     $companyDealerDto = $serviceCompanyDealersManager->getByCompanyIdAndUserId($userId, $service_company_id);
     if (!isset($companyDealerDto)) {
         $serviceCompanyDealersManager->addUserToCompany($userId, $service_company_id);
         $message = $this->getPhrase(437) . ' ' . $serviceCompany->getName() . "'! \n";
         $this->ok(array("message" => $message));
     } else {
         $this->error(array("errText" => "You already have '" . $serviceCompany->getName() . "' company in your list!"));
     }
 }