public async Task<ClientCategoryModel> EditClientCategoryAsync(ClientCategoryModel clientCategory) { using (var client = new HttpClient()) { List<KeyValuePair<string, string>> values = HelperMethods.CreateKeyValuePairsFromReflection(clientCategory); client.DefaultRequestHeaders.Authorization = HelperMethods.CreateAuthorizationHeader(_apiKey); var content = new FormUrlEncodedContent(values); HttpResponseMessage response = await client.PutAsync(BaseRequestUri, content); return await GetClientCategoryByIdAsync(clientCategory.CategoryID); } }
public async Task<ClientCategoryModel> CreateClientCategoryAsync(ClientCategoryModel clientCategory) { using (var client = new HttpClient()) { List<KeyValuePair<string, string>> values = HelperMethods.CreateKeyValuePairsFromReflection(clientCategory); 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<ClientCategoryModel>(responseString); } }