Ejemplo n.º 1
0
 /// <summary>
 /// Adds comment to current update
 /// </summary>
 /// <param name="comment">Comment to add</param>
 /// <returns>Value containing true or false, depending on operation success, and response status</returns>
 /// <exception cref="LinkedInInvalidOperationException">Thrown when current update is not commentable</exception>
 public LinkedInResponse <bool> Comment(string comment)
 {
     try
     {
         if (!IsCommentable)
         {
             throw new LinkedInInvalidOperationException("Comments are not allowed for this update");
         }
         if (comment.Length > LinkedInShareOptions.MAX_COMMENT_LENGTH)
         {
             comment = comment.Substring(0, LinkedInShareOptions.MAX_COMMENT_LENGTH);
         }
         var response  = RequestRunner.CommentUpdate(UpdateKey, comment);
         var liComment = getLastComment();
         if (liComment != null)
         {
             _Comments.Add(liComment);
         }
         NumberOfComments++;
         return(response);
     }
     catch (WebException wex)
     {
         return(Utils.GetResponse(false, wex, null));
     }
     catch (Exception ex)
     {
         return(new LinkedInResponse <bool>(false, LinkedInResponseStatus.OtherException, null, ex));
     }
 }