narsil/Tanshu.Accounts.Repository/MachineLocationBI.cs

52 lines
1.8 KiB
C#
Raw Normal View History

2018-08-24 10:41:33 +00:00
using RestSharp;
using System;
using System.Collections.Generic;
2018-08-24 10:41:33 +00:00
using Tanshu.Accounts.Entities;
namespace Tanshu.Accounts.Repository
{
2018-08-24 10:41:33 +00:00
public static class MachineLocationBI
{
2018-08-24 10:41:33 +00:00
public static IList<MachineLocation> List()
{
var request = new RestRequest();
request.Resource = "MachineLocations.json";
return JsonStore.Execute<List<MachineLocation>>(request);
}
public static MachineLocation Get(string machineName)
{
var request = new RestRequest();
request.Resource = "MachineLocation.json";
request.AddQueryParameter("n", machineName);
return JsonStore.Execute<MachineLocation>(request);
}
public static MachineLocation Get(Guid id)
{
var request = new RestRequest();
request.Resource = "MachineLocation/{id}.json";
request.AddParameter("id", id, ParameterType.UrlSegment);
return JsonStore.Execute<MachineLocation>(request);
}
public static MachineLocation Insert(MachineLocation machineLocation)
{
2018-08-24 10:41:33 +00:00
var request = new RestRequest(Method.PUT);
request.Resource = "MachineLocation.json";
request.AddJsonBody(machineLocation);
return JsonStore.Execute<MachineLocation>(request);
}
2018-08-24 10:41:33 +00:00
public static MachineLocation Update(MachineLocation machineLocation)
{
var request = new RestRequest(Method.POST);
request.Resource = "MachineLocation/{id}.json";
request.AddParameter("id", machineLocation.MachineLocationID, ParameterType.UrlSegment);
request.AddJsonBody(machineLocation);
return JsonStore.Execute<MachineLocation>(request);
}
}
}