2018-08-24 10:41:33 +00:00
|
|
|
|
using RestSharp;
|
|
|
|
|
using System;
|
2011-06-29 20:27:07 +00:00
|
|
|
|
using System.Collections.Generic;
|
2018-08-24 10:41:33 +00:00
|
|
|
|
using System.Linq;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Entities;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
public class ProductGroupBI
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
public static IList<ProductGroup> List()
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "ProductGroups.json";
|
|
|
|
|
return JsonStore.Execute<List<ProductGroup>>(request);
|
2011-06-29 20:27:07 +00:00
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
|
|
|
|
|
public static ProductGroup Get(Guid id)
|
2011-06-29 20:27:07 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "ProductGroup/{id}.json";
|
|
|
|
|
request.AddParameter("id", id, ParameterType.UrlSegment);
|
|
|
|
|
return JsonStore.Execute<ProductGroup>(request);
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
2014-11-02 08:03:31 +00:00
|
|
|
|
|
2018-08-24 10:41:33 +00:00
|
|
|
|
public static ProductGroup Insert(ProductGroup productGroup)
|
|
|
|
|
{
|
|
|
|
|
var request = new RestRequest(Method.PUT);
|
|
|
|
|
request.Resource = "ProductGroup.json";
|
|
|
|
|
request.AddJsonBody(productGroup);
|
|
|
|
|
return JsonStore.Execute<ProductGroup>(request);
|
2014-11-02 08:03:31 +00:00
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
|
|
|
|
|
public static ProductGroup Update(ProductGroup productGroup)
|
2011-02-18 16:54:48 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest(Method.POST);
|
|
|
|
|
request.Resource = "ProductGroup/{id}.json";
|
|
|
|
|
request.AddParameter("id", productGroup.ProductGroupID, ParameterType.UrlSegment);
|
|
|
|
|
request.AddJsonBody(productGroup);
|
|
|
|
|
return JsonStore.Execute<ProductGroup>(request);
|
2011-02-18 16:54:48 +00:00
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
|
|
|
|
|
public static IList<ProductGroup> SaleList()
|
2011-01-31 20:33:22 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "ProductGroups.json";
|
|
|
|
|
request.AddQueryParameter("s", "");
|
|
|
|
|
var list = JsonStore.Execute<List<ProductGroup>>(request);
|
|
|
|
|
foreach (var item in list)
|
2011-01-31 20:33:22 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
foreach (var product in item.Products)
|
|
|
|
|
{
|
|
|
|
|
product.ProductGroup = item;
|
|
|
|
|
}
|
2011-01-31 20:33:22 +00:00
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
return list;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2018-08-24 10:41:33 +00:00
|
|
|
|
public static IList<string> GetProductGroupTypes()
|
2014-10-12 09:41:45 +00:00
|
|
|
|
{
|
2018-08-24 10:41:33 +00:00
|
|
|
|
var request = new RestRequest();
|
|
|
|
|
request.Resource = "ProductGroupTypes.json";
|
|
|
|
|
return JsonStore.Execute<List<string>>(request);
|
|
|
|
|
}
|
|
|
|
|
public static void UpdateSortOrder(IList<ProductGroup> list)
|
|
|
|
|
{
|
|
|
|
|
var request = new RestRequest(Method.POST);
|
|
|
|
|
request.Resource = "ProductGroups.json";
|
|
|
|
|
request.AddJsonBody(list.Select(x => new { ProductGroupID = x.ProductGroupID }));
|
|
|
|
|
JsonStore.Execute<Boolean>(request);
|
2014-10-12 09:41:45 +00:00
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|