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 removeStory($storyId)
 {
     $success = StoryRepository::remove($storyId);
     if ($success) {
         $this->sendResponse(array('success' => true));
     } else {
         $this->sendOperationFailedResult('Story');
     }
 }