2011-01-30 07:14:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using System.Linq.Expressions;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
using Tanshu.Accounts.Entities;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using NHibernate;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
|
|
|
{
|
2011-06-29 20:27:07 +00:00
|
|
|
|
public class ProductBI : FluentGenericBase<Product>
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public ProductBI()
|
|
|
|
|
: base()
|
|
|
|
|
{ }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public ProductBI(bool beginTransaction)
|
|
|
|
|
: base(beginTransaction)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
public ProductBI(ISession session)
|
|
|
|
|
: base(session)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
public ProductBI(ISession session, bool beginTransaction)
|
|
|
|
|
: base(session, beginTransaction)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Product Get(string nameAndUnits)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Get(x => x.Name + " (" + x.Units + ")" == nameAndUnits);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public new IList<Product> List(Expression<Func<Product, bool>> query)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-29 20:27:07 +00:00
|
|
|
|
var list = Query()
|
|
|
|
|
.Where(query)
|
|
|
|
|
.OrderBy(x => x.SortOrder).Asc
|
|
|
|
|
.ThenBy(x => x.Name).Asc
|
|
|
|
|
.List();
|
2011-06-23 12:47:48 +00:00
|
|
|
|
foreach (var item in list)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
NHibernateUtil.Initialize(item.ProductGroup);
|
|
|
|
|
NHibernateUtil.Initialize(item.Tax);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return list;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
|
|
|
|
|
public new IList<Product> List()
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-29 20:27:07 +00:00
|
|
|
|
var list = Query()
|
|
|
|
|
.OrderBy(x => x.ProductGroup).Asc
|
|
|
|
|
.ThenBy(x => x.SortOrder).Asc
|
|
|
|
|
.ThenBy(x => x.Name).Asc
|
|
|
|
|
.List();
|
2011-06-23 12:47:48 +00:00
|
|
|
|
foreach (var item in list)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
NHibernateUtil.Initialize(item.ProductGroup);
|
|
|
|
|
NHibernateUtil.Initialize(item.Tax);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return list;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<ProductDisplaySmall> GetFilteredProducts(Dictionary<string, string> filter)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<ProductDisplaySmall> GetUnFilteredProducts()
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, string> filter = new Dictionary<string, string>();
|
|
|
|
|
filter.Add("Name", "");
|
|
|
|
|
filter.Add("Type", "");
|
|
|
|
|
return GetFilteredProducts(filter);
|
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public static IList<Product> List(int productGroupID)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
|
|
|
|
using (var session = SessionManager.Session)
|
|
|
|
|
{
|
2011-01-31 20:33:22 +00:00
|
|
|
|
return (from product in session.QueryOver<Product>()
|
|
|
|
|
where product.ProductGroup.ProductGroupID == productGroupID
|
|
|
|
|
select product).List();
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|