narsil/Tanshu.Accounts.SqlDAO/BusinessLayer/ProductGroupBI.cs

56 lines
1.5 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Text;
using Tanshu.Accounts.Contracts;
using System.Data.SqlClient;
using Tanshu.Data.DAO;
using Tanshu.Accounts.Entities;
using Tanshu.Accounts.SqlDAO;
using NHibernate.Criterion;
namespace Tanshu.Accounts.Repository
{
public class ProductGroupBI
{
public ProductGroup GetProductGroup(int productGroupID)
{
using (var session = SessionManager.Session)
{
return session.Get<ProductGroup>(productGroupID);
}
}
public ProductGroup GetProductGroupByName(string name)
{
using (var session = SessionManager.Session)
{
return session.CreateCriteria<ProductGroup>()
.Add(Restrictions.Eq("Name", name))
.UniqueResult<ProductGroup>();
}
}
public void Insert(ProductGroup productGroup)
{
using (var session = SessionManager.Session)
{
session.Save(productGroup);
}
}
public void Update(ProductGroup productGroup)
{
using (var session = SessionManager.Session)
{
session.Update(productGroup);
}
}
public IList<ProductGroup> GetProductGroups()
{
using (var session = SessionManager.Session)
{
return session.CreateCriteria<ProductGroup>()
.List<ProductGroup>();
}
}
}
}