narsil/Tanshu.Accounts.Repository/BusinessLayer/ProductGroupModifierBI.cs

47 lines
1.6 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using Tanshu.Accounts.Entities;
using NHibernate;
namespace Tanshu.Accounts.Repository
{
public class ProductGroupModifierBI : FluentGenericBase<ProductGroupModifier>
{
public ProductGroupModifierBI()
: base()
{ }
public ProductGroupModifierBI(bool beginTransaction)
: base(beginTransaction)
{ }
public ProductGroupModifierBI(ISession session)
: base(session)
{ }
public ProductGroupModifierBI(ISession session, bool beginTransaction)
: base(session, beginTransaction)
{ }
public IList<Modifier> List(int productGroupID)
{
var list = (from pgm in Session.QueryOver<ProductGroupModifier>()
where pgm.ProductGroup == null || pgm.ProductGroup.ProductGroupID == productGroupID
select pgm.Modifier).Fetch(x => x.Modifier).Eager.List<Modifier>();
foreach (var item in list)
NHibernateUtil.Initialize(item);
return list;
}
public bool HasCompulsoryModifier(int productGroupID)
{
using (var session = SessionManager.Session)
{
var l = from gf in session.QueryOver<ProductGroupModifier>()
where gf.ShowAutomatically == true && (gf.ProductGroup == null || gf.ProductGroup.ProductGroupID == productGroupID)
select gf;
int c = l.RowCount();
return c > 0;
}
}
}
}