Exemple #1
0
 public int DeletePost(PostViewModel postViewModel)
 {
     try
     {
         var result = PostServiceHttpClient.PostAsync(ADDRESS + "deletepost", new StringContent(JsonConvert.SerializeObject(postViewModel), Encoding.UTF8, "application/json")).Result;
         return(result.Content.ReadAsAsync <int>().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Exemple #2
0
 public int UpdatePost(PostViewModel postViewModel, List <CategoryViewModel> categoryViewModelList)
 {
     try
     {
         postViewModel.Categories = categoryViewModelList.ToArray();
         var result = PostServiceHttpClient.PostAsync(ADDRESS + "updatepost", new StringContent(JsonConvert.SerializeObject(postViewModel), Encoding.UTF8, "application/json")).Result;
         return(result.Content.ReadAsAsync <int>().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }