51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Tanshu.Accounts.Entities;
|
|
using RestSharp;
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
public static class CustomerBI
|
|
{
|
|
public static IList<Customer> List()
|
|
{
|
|
var request = new RestRequest();
|
|
request.Resource = "Customers.json";
|
|
return JsonStore.Execute<List<Customer>>(request);
|
|
}
|
|
|
|
public static Customer Get(Guid id)
|
|
{
|
|
var request = new RestRequest();
|
|
request.Resource = "Customer/{id}.json";
|
|
request.AddParameter("id", id, ParameterType.UrlSegment);
|
|
return JsonStore.Execute<Customer>(request);
|
|
}
|
|
|
|
public static bool Delete(Guid id)
|
|
{
|
|
var request = new RestRequest(Method.DELETE);
|
|
request.Resource = "Customer/{id}.json";
|
|
request.AddParameter("id", id, ParameterType.UrlSegment);
|
|
return JsonStore.Execute<Boolean>(request);
|
|
}
|
|
|
|
public static Customer Insert(Customer customer)
|
|
{
|
|
var request = new RestRequest(Method.PUT);
|
|
request.Resource = "Customer.json";
|
|
request.AddJsonBody(customer);
|
|
return JsonStore.Execute<Customer>(request);
|
|
}
|
|
|
|
public static Customer Update(Customer customer)
|
|
{
|
|
var request = new RestRequest(Method.POST);
|
|
request.Resource = "Customer/{id}.json";
|
|
request.AddParameter("id", customer.CustomerID, ParameterType.UrlSegment);
|
|
request.AddJsonBody(customer);
|
|
return JsonStore.Execute<Customer>(request);
|
|
}
|
|
}
|
|
}
|