using System; using System.Collections.Generic; using Tanshu.Accounts.Entities; using System.Linq; using RestSharp; namespace Tanshu.Accounts.Repository { public static class FoodTableBI { public static IList List(bool? active) { var request = new RestRequest(); request.Resource = "FoodTables.json"; if (active.HasValue) request.AddQueryParameter("a", active.Value.ToString()); return JsonStore.Execute>(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(request); } public static FoodTable GetFromVoucher(Guid id) { var request = new RestRequest(); request.Resource = "FoodTable.json"; request.AddQueryParameter("v", id.ToString()); return JsonStore.Execute(request); } public static FoodTable GetFromName(string name) { var request = new RestRequest(); request.Resource = "FoodTable/{id}.json"; request.AddParameter("id", name, ParameterType.UrlSegment); return JsonStore.Execute(request); } public static FoodTable Insert(FoodTable foodTable) { var request = new RestRequest(Method.PUT); request.Resource = "FoodTable.json"; request.AddJsonBody(foodTable); return JsonStore.Execute(request); } 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(request); } public static void UpdateSortOrder(IList list) { var request = new RestRequest(Method.POST); request.Resource = "FoodTables.json"; request.AddJsonBody(list.Select(x => new { FoodTableID = x.FoodTableID })); JsonStore.Execute(request); } } }