69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
//using System.Linq;
|
|
using System.Text;
|
|
using Tanshu.Accounts.Contracts;
|
|
using System.Data.SqlClient;
|
|
using Tanshu.Data.DAO;
|
|
using Tanshu.Accounts.SqlDAO;
|
|
using Tanshu.Accounts.Entities;
|
|
using NHibernate.Criterion;
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
public class CustomerBI
|
|
{
|
|
public Customer GetCustomer(int customerID)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
return session.Get<Customer>(customerID);
|
|
}
|
|
}
|
|
public IList<Customer> GetCustomers()
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
return session.CreateCriteria<Customer>().List<Customer>();
|
|
}
|
|
}
|
|
public IList<Customer> GetSingleCustomers(int customerID)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
return session.CreateCriteria<Customer>()
|
|
.Add(Restrictions.Eq("CustomerID", customerID))
|
|
.List<Customer>();
|
|
}
|
|
}
|
|
public void Update(Customer customer)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
session.Update(customer);
|
|
}
|
|
}
|
|
public bool Delete(int customerID)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
session.Delete(new Customer() { CustomerID = customerID });
|
|
return true;
|
|
}
|
|
}
|
|
public void Insert(Customer customer)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
session.Save(customer);
|
|
}
|
|
}
|
|
|
|
public List<Customer> GetFilteredCustomers(Dictionary<string, string> filter)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|