2018-08-24 10:41:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-03-11 18:49:48 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
2011-04-11 12:55:45 +00:00
|
|
|
|
using System.Linq;
|
2018-08-24 10:41:33 +00:00
|
|
|
|
using RestSharp;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
public static class FoodTableBI
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
public static IList<FoodTable> List(bool? active)
|
|
|
|
|
{
|
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "FoodTables.json";
|
|
|
|
|
if (active.HasValue)
|
|
|
|
|
request.AddQueryParameter("a", active.Value.ToString());
|
|
|
|
|
return JsonStore.Execute<List<FoodTable>>(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FoodTable Get(Guid id)
|
|
|
|
|
{
|
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "FoodTable/{id}.json";
|
|
|
|
|
request.AddParameter("id", id, ParameterType.UrlSegment);
|
|
|
|
|
return JsonStore.Execute<FoodTable>(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FoodTable GetFromVoucher(Guid id)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "FoodTable.json";
|
|
|
|
|
request.AddQueryParameter("v", id.ToString());
|
|
|
|
|
return JsonStore.Execute<FoodTable>(request);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
|
|
|
|
|
public static FoodTable GetFromName(string name)
|
|
|
|
|
{
|
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "FoodTable/{id}.json";
|
|
|
|
|
request.AddParameter("id", name, ParameterType.UrlSegment);
|
|
|
|
|
return JsonStore.Execute<FoodTable>(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static FoodTable Insert(FoodTable foodTable)
|
2014-10-16 11:11:55 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest(Method.PUT);
|
|
|
|
|
request.Resource = "FoodTable.json";
|
|
|
|
|
request.AddJsonBody(foodTable);
|
|
|
|
|
return JsonStore.Execute<FoodTable>(request);
|
2014-10-16 11:11:55 +00:00
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
|
|
|
|
|
public static FoodTable Update(FoodTable foodTable)
|
|
|
|
|
{
|
|
|
|
|
var request = new RestRequest(Method.POST);
|
|
|
|
|
request.Resource = "FoodTable/{id}.json";
|
|
|
|
|
request.AddParameter("id", foodTable.FoodTableID, ParameterType.UrlSegment);
|
|
|
|
|
request.AddJsonBody(foodTable);
|
|
|
|
|
return JsonStore.Execute<FoodTable>(request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UpdateSortOrder(IList<FoodTable> list)
|
2014-10-16 11:11:55 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest(Method.POST);
|
|
|
|
|
request.Resource = "FoodTables.json";
|
|
|
|
|
request.AddJsonBody(list.Select(x => new { FoodTableID = x.FoodTableID }));
|
|
|
|
|
JsonStore.Execute<Boolean>(request);
|
2014-10-16 11:11:55 +00:00
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|