Skip to content

Instantly share code, notes, and snippets.

@mr5z
Last active April 20, 2021 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mr5z/1d71c7d92485c8418d3cb98e81259ef9 to your computer and use it in GitHub Desktop.
Save mr5z/1d71c7d92485c8418d3cb98e81259ef9 to your computer and use it in GitHub Desktop.
Y_Y
IProductGet : IGet<List<Product>>
IProductPost : IPost<Product, Product>
IProductDelete : IDelete<Product, long>
class ProductRest :
IProductGet,
IProductPost,
IProductDelete
{
public async Task<List<Product>> Get(CancellationToken cancellationToken)
{
var response = await httpClient.Get<List<Product>>(path, cancellationToken);
return new List<Product>(response);
}
public async Task<Product> Post(Product product, CancellationToken cancellationToken)
{
var response = await httpClient.Post<Product>(path, product, cancellationToken);
return response;
}
public async Task<Product> Delete(long id, CancellationToken cancellationToken)
{
var response = await httpClient.Delete<Product>(path, new { id }, cancellationToken);
return response;
}
}
// issues: path generation, input generation, tedious
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment