public function sendOtp()
 {
     $this->autoRender = false;
     $json = $this->request->input();
     $userOtp = DTO\ClsUserDto::Deserialize($json);
     $userToEmailid = $userOtp->emailId;
     if (empty($userToEmailid)) {
         $this->response->body(\App\DTO\ClsErrorDto::prepareError(118));
         //$this->response->send();
         return;
     }
     $otp = rand(1000, 999999);
     $subject = OTP_EMAIL_SUBJECT;
     $message = sprintf(OTP_EMAIL_BODY, $otp);
     //Update the OTP in database
     $result = $this->getTableObj()->updateOtp($userOtp->userId, $otp);
     $emailClient = new \Cake\Mailer\Email('default');
     $emailClient->addBcc('*****@*****.**', 'Anand Kulkarni');
     $emailClient->subject($subject);
     $emailClient->to($userToEmailid);
     $emailClient->send($message);
     if ($result) {
         $this->response->body(\App\DTO\ClsErrorDto::prepareSuccessMessage("verification email was sent to email : " . $userToEmailid));
         //$this->response->send();
         return;
     } else {
         $this->response->body(\App\DTO\ClsErrorDto::prepareError(115));
         //$this->response->send();
         return;
     }
 }
 public function up()
 {
     $this->autoRender = false;
     // $json = null;
     $json = $this->request->input();
     \Cake\Log\Log::debug("Upload request input json : " . $json);
     \Cake\Log\Log::debug("Checking is request empty or not");
     if (empty($json)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(104));
         \Cake\Log\Log::error("User requested with invalid data");
         return;
     }
     $arr = DTO\ClsUploadDeserializerDto::Deserialize($json);
     if (empty($arr->user) or empty($arr->data)) {
         // $this->response->body(DTO\ClsErrorDto::prepareError(117));
         return;
     }
     $user = DTO\ClsUserDto::Deserialize($arr->user);
     if ($this->userValidation($user->userId, $user->emailId, $user->userName)) {
         $senderUserId = $user->userId;
         foreach ($arr->data as $index => $record) {
             \Cake\Log\Log::info('Index : ' . $index . 'Record :' . $record->tableName);
             switch ($record->tableName) {
                 case $this->table['TC']:
                     \Cake\Log\Log::info("Comment section");
                     $commentDto = DTO\ClsCommentAndLikeDto::Deserialize($record->tableData);
                     $this->uploadComment($senderUserId, $commentDto);
                     break;
                 case $this->table['TL']:
                     $likeDto = DTO\ClsCommentAndLikeDto::Deserialize($record->tableData);
                     $this->uploadLike($user->userId, $likeDto);
                     break;
                 case $this->table['TA']:
                     $answerDto = DTO\ClsAnswerDto::Deserialize($record->tableData);
                     \Cake\Log\Log::debug("Accepted Answer data");
                     $this->uploadAnswer($user->userId, $answerDto);
                     break;
                     //                    case $this->table['TU']:
                     //                        $userDto = DTO\ClsUserDto::Deserialize($record->tableData);
                     //                        $this->uploadUser($user->userId,$userDto);
                     //                        break;
                     //                    case $this->table['TI']:
                     //                        $imageDto = DTO\ClsImagesDto::Deserialize($record->tableData);
                     //                        $this->image($imageDto);
                     //                        break;
             }
         }
     } else {
         $this->response->body(DTO\ClsErrorDto::prepareError(100));
     }
 }
 public function update()
 {
     $this->autoRender = false;
     $userInfo = $this->request->input();
     \Cake\Log\Log::debug("User information request input json for update : " . $userInfo);
     if (empty($userInfo)) {
         $this->response->body(DTO\ClsErrorDto::prepareError(107));
         \Cake\Log\Log::error("User information is empty");
         return FAIL;
     }
     \Cake\Log\Log::debug("Update user json : " . $userInfo);
     $userDto = DTO\ClsUserDto::Deserialize($userInfo);
     if (isset($userDto->password)) {
         $this->updateWithOtp($userDto);
     } else {
         $this->updateUserInfo($userDto);
     }
 }