Esempio n. 1
0
 public IEnumerable <CategoryViewModel> GetBlogCategories(string userName)
 {
     try
     {
         var result = CategoryServiceHttpClient.GetAsync(ADDRESS + "getblogcategories/" + userName).Result;
         return(result.Content.ReadAsAsync <IEnumerable <CategoryViewModel> >().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Esempio n. 2
0
 public IEnumerable <CategoryViewModel> GetPostCategories(int postId)
 {
     try
     {
         var result = CategoryServiceHttpClient.GetAsync(ADDRESS + "getpostcategories/" + postId).Result;
         return(result.Content.ReadAsAsync <IEnumerable <CategoryViewModel> >().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Esempio n. 3
0
 public int DeleteCategory(CategoryViewModel categoryViewModel)
 {
     try
     {
         var result = CategoryServiceHttpClient.PostAsync(ADDRESS + "deletecategory", new StringContent(JsonConvert.SerializeObject(categoryViewModel), Encoding.UTF8, "application/json")).Result;
         return(result.Content.ReadAsAsync <int>().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }
Esempio n. 4
0
 public IEnumerable <CategoryViewModel> GetAllCategories()
 {
     try
     {
         var result = CategoryServiceHttpClient.GetAsync(ADDRESS + "getallcategories").Result;
         return(result.Content.ReadAsAsync <IEnumerable <CategoryViewModel> >().Result);
     }
     catch (FaultException xe)
     {
         throw new ApplicationException(xe.Message);
     }
 }
Esempio n. 5
0
 public CategoryViewModel GetCategoryById(int categoryId)
 {
     try
     {
         var result = CategoryServiceHttpClient.GetAsync(ADDRESS + "getcategorybyid/" + categoryId).Result;
         return(result.Content.ReadAsAsync <CategoryViewModel>().Result);
     }
     catch (FaultException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }