public async Task<ProductCategoryGroupModel> CreateProductCategoryGroupAsync(ProductCategoryGroupModel ProductCategoryGroup) { using (var client = new HttpClient()) { var values = HelperMethods.CreateKeyValuePairsFromReflection(ProductCategoryGroup); client.DefaultRequestHeaders.Authorization = HelperMethods.CreateAuthorizationHeader(_apiKey); var content = new FormUrlEncodedContent(values); HttpResponseMessage response = await client.PostAsync(BaseRequestUri, content); string responseString = await response.Content.ReadAsStringAsync(); return JsonConvert.DeserializeObject<ProductCategoryGroupModel>(responseString); } }
public async Task<ProductCategoryGroupModel> EditProductCategoryGroupAsync(ProductCategoryGroupModel ProductCategoryGroup) { using (var client = new HttpClient()) { var values = HelperMethods.CreateKeyValuePairsFromReflection(ProductCategoryGroup); client.DefaultRequestHeaders.Authorization = HelperMethods.CreateAuthorizationHeader(_apiKey); var content = new FormUrlEncodedContent(values); HttpResponseMessage response = await client.PutAsync(BaseRequestUri, content); return await GetProductCategoryGroupByIdAsync(ProductCategoryGroup.GroupID); } }