narsil/Tanshu.Accounts.Repository/FoodTableBI.cs

69 lines
2.4 KiB
C#
Raw Permalink Normal View History

2018-08-24 10:41:33 +00:00
using System;
using System.Collections.Generic;
using Tanshu.Accounts.Entities;
using System.Linq;
2018-08-24 10:41:33 +00:00
using RestSharp;
namespace Tanshu.Accounts.Repository
{
2018-08-24 10:41:33 +00:00
public static class FoodTableBI
{
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)
{
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);
}
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)
{
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);
}
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)
{
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);
}
}
}