Skip to content

Commit

Permalink
fix README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
noamyogev84 committed Aug 23, 2018
1 parent 3be5816 commit ba0f7bd
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,42 @@
# Examples

```csharp
public class SomeClass
public class HttpClientConsumer
{
public string BaseUrl { get; set; }
private IHttpClient _client;

[importing constructor]
public SomeClass(IHttpClient client) {
public HttpClientConsumer(IHttpClient client) {
_client = client;
client.BaseAddress = BaseUrl;
_client.BaseAddress = BaseUrl;
}

//Get
public async IEnumerable<CustomrerDto> GetCustomersAsync() {
return await _client.GetAsync<IEnumerable<CustomerDto>>("customers");
IHttpResult result = await _client.GetAsync<IEnumerable<CustomerDto>>("customers");
return result.Content;
}

//Post
public async void CreateCustomerAsync(CustomerDto customer) {
var result = await _client.PostAsync<CustomerDto,object>("customers",customer);
IHttpResult result = await _client.PostAsync<CustomerDto>("customers",customer);
//handle result...
}

//Put
public async void ReplaceCustomerAsync(CustomerUpdateDto customer) {
var result = await _client.PutAsync<CustomerUpdateDto,object>($"customers/{customer.id}",customer);
IHttpResult result = await _client.PutAsync<CustomerUpdateDto>($"customers/{customer.id}",customer);
}

//Patch
public async void UpdateCustomerAsync(CustomerPatchDoc patchDoc) {
var result = await _client.PatchAsync<CustomerPatchDoc,object>($"customers/{patchDoc.id}", patchDoc);
IHttpResult result = await _client.PatchAsync<CustomerPatchDoc>($"customers/{patchDoc.id}", patchDoc);
}

//Delete
public async void RemoveCustomerAsync(CustomerDto customer) {
var result = await _client.DeleteAsync<object>($"customers/{customer.id}");
IHttpResult result = await _client.DeleteAsync($"customers/{customer.id}");
}
}
```

0 comments on commit ba0f7bd

Please sign in to comment.