public function add($storyId)
 {
     $reqData = $this->getDataFromRequestWithJsonFormat();
     if (!isset($reqData['UserId']) || intval($reqData['UserId']) <= 0) {
         $this->sendResponse(array('success' => false, 'message' => 'Invalid user!'));
     }
     $userId = intval($reqData['UserId']);
     if (!isset($reqData['Body']) || empty($reqData['Body'])) {
         $this->sendResponse(array('success' => false, 'message' => 'Invalid comment content!'));
     }
     $body = htmlspecialchars($reqData['Body']);
     $comment = array('UserId' => $userId, 'StoryId' => $storyId, 'Deep' => 0, 'CreatedDate' => date('Y-m-d H:i:s'), 'Body' => $body);
     if (isset($reqData['ParentId'])) {
         $comment['ParentId'] = intval($reqData['ParentId']);
         $parent = CommentRepository::findCommentById($comment['ParentId']);
         if ($parent) {
             $comment['Deep'] = $parent['Deep'] + 1;
         }
     }
     $newId = CommentRepository::save($comment);
     if ($newId) {
         $story = StoryRepository::findStoryById($storyId);
         $activity = array('SenderId' => $userId, 'ReceiverId' => $story['UserId'], 'Type' => ActivityType::CommentStory, 'StoryId' => $storyId, 'CommentId' => $newId, 'CreatedDate' => date('Y-m-d H:i:s'));
         ActivityRepository::save($activity);
         $comment['CommentId'] = $newId;
         $this->sendResponse(array('success' => true, 'comment' => $comment));
     } else {
         $this->sendOperationFailedResult('Comment');
     }
 }
 public function updateStoryStatus($storyId)
 {
     $reqData = $this->getDataFromRequestWithJsonFormat();
     if (!isset($reqData['UserId']) || intval($reqData['UserId']) <= 0) {
         $this->sendResponse(array('success' => false, 'message' => 'Invalid user!'));
     }
     $userId = intval($reqData['UserId']);
     if (!isset($reqData['Status']) || intval($reqData['Status']) <= 0) {
         $this->sendResponse(array('success' => false, 'message' => 'Invalid status!'));
     }
     $status = intval($reqData['Status']);
     $story = StoryRepository::findStoryById($storyId);
     if ($status == UpdateStoryStatus::Report) {
     }
     if ($status == UpdateStoryStatus::View) {
         $story['ViewCount'] += 1;
         StoryRepository::update($story['StoryId'], $story);
     }
     if ($status == UpdateStoryStatus::Play) {
         $story['PlayCount'] += 1;
         StoryRepository::update($story['StoryId'], $story);
     }
     if ($status == UpdateStoryStatus::Share) {
         $story['SharedCount'] += 1;
         StoryRepository::update($story['StoryId'], $story);
     }
     $this->sendResponse(array('success' => true));
 }