Пример #1
0
 public function index()
 {
     $this->autoRender = false;
     $userId = $this->request->query("userId");
     $restaurantId = $this->request->query("restaurantId");
     \Cake\Log\Log::debug("Download request come with userId  :- " . $userId . ' restaurantId :- ' . $restaurantId);
     if (empty($userId) or empty($restaurantId)) {
         $this->response->body(DTO\ErrorDto::prepareError(101));
         \Cake\Log\Log::error("userId or restaurantID is blank ");
         return;
     }
     $restaurantController = new RestaurantController();
     if (!$restaurantController->isValidate($restaurantId)) {
         $this->response->body(DTO\ErrorDto::prepareError(100));
         \Cake\Log\Log::error("request with incorrect restaurantId :- " . $restaurantId);
         return;
     }
     $userController = new UserController();
     if (!$userController->isUserValid($userId, $restaurantId)) {
         $this->response->body(DTO\ErrorDto::prepareError(102));
         \Cake\Log\Log::error("request with incorrect  userId :- " . $userId);
         return;
     }
     \Cake\Log\Log::debug('Download request is validate successfully ');
     $syncController = new SyncController();
     $syncController->download($userId, $restaurantId);
 }
 public function index()
 {
     $this->autoRender = false;
     $userId = $this->request->query("userid");
     \Cake\Log\Log::debug("Download request input querystring userId is : " . $userId);
     if (empty($userId)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(101));
         \Cake\Log\Log::error("userId is blank " . $userId);
         return;
     }
     $userDto = new DTO\ClsUserDto($userId);
     if ($this->isValied($userDto->userId)) {
         \Cake\Log\Log::debug("User validate");
         $syncController = new SyncController();
         $syncController->download($userDto->userId);
     } else {
         $this->response->body(DTO\ClsErrorDto::prepareError(102));
         \Cake\Log\Log::error("User requested with invalid userid : " . $userId);
     }
 }