Example #1
0
 public CommentViewModel GetComment(int commentId)
 {
     try
     {
         var result = CommentServiceHttpClient.GetAsync(ADDRESS + "getcomment/" + commentId).Result;
         return(result.Content.ReadAsAsync <CommentViewModel>().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Example #2
0
 public int DeleteComment(CommentViewModel commentViewModel)
 {
     try
     {
         var result = CommentServiceHttpClient.PostAsync(ADDRESS + "deletecomment", new StringContent(JsonConvert.SerializeObject(commentViewModel), Encoding.UTF8, "application/json")).Result;
         return(result.Content.ReadAsAsync <int>().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Example #3
0
 public IEnumerable <CommentViewModel> GetIndependentComments(int postId)
 {
     try
     {
         var result = CommentServiceHttpClient.GetAsync(ADDRESS + "getindependentcomments/" + postId).Result;
         return(result.Content.ReadAsAsync <IEnumerable <CommentViewModel> >().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Example #4
0
 public bool HaveMoreThanFourLevels(CommentViewModel commentViewModel)
 {
     try
     {
         var result = CommentServiceHttpClient.PostAsync(ADDRESS + "havemorethanfourlevels", new StringContent(JsonConvert.SerializeObject(commentViewModel), Encoding.UTF8, "application/json")).Result;
         return(result.Content.ReadAsAsync <bool>().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }