public IEnumerable <PostViewModel> GetPostsByUserNameWithoutCategory(string userName) { try { var result = PostServiceHttpClient.GetAsync(ADDRESS + "getuserpostswithoutcategory/" + userName).Result; return(result.Content.ReadAsAsync <IEnumerable <PostViewModel> >().Result); } catch (FaultException ex) { throw new ApplicationException(ex.Message); } }
public IEnumerable <PostViewModel> GetUserPostsByUserName(string userName) { try { var result = PostServiceHttpClient.GetAsync(ADDRESS + "getuserpostsbyusername/" + userName).Result; return(result.Content.ReadAsAsync <PostViewModel[]>().Result.ToEnumerable()); } catch (FaultException ex) { throw new ApplicationException(ex.Message); } }
public IEnumerable <PostViewModel> GetUserPosts(int userId) { try { var result = PostServiceHttpClient.GetAsync(ADDRESS + "getuserposts/" + userId).Result; return(result.Content.ReadAsAsync <IEnumerable <PostViewModel> >().Result); } catch (FaultException ex) { throw new ApplicationException(ex.Message); } }
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); } }
public PostViewModel GetPost(int postId) { try { var result = PostServiceHttpClient.GetAsync(ADDRESS + "getpost/" + postId).Result; return(result.Content.ReadAsAsync <PostViewModel>().Result); } catch (FaultException ex) { throw new ApplicationException(ex.Message); } }
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); } }