narsil/Tanshu.Accounts.BI/CustomerBI.cs
2011-12-05 14:53:02 +05:30

110 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
using Tanshu.Accounts.Contracts;
using System.Data.SqlClient;
using Tanshu.Accounts.DAOFactory;
using Tanshu.Data.DAO;
namespace Tanshu.Accounts.BI
{
public class CustomerBI : ICustomerBI
{
public List<LedgerBO> GetCustomerLedgers()
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
return dao.GetCustomerLedgers();
}
}
}
public CustomerBO GetCustomer(Guid customerID)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
return dao.GetCustomer(customerID);
}
}
}
public List<CustomerBO> GetFilteredCustomers(Dictionary<string, string> filter)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
return dao.GetFilteredCustomers(filter);
}
}
}
public List<CustomerBO> GetCustomers()
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
return dao.GetCustomers();
}
}
}
public List<CustomerBO> GetSingleCustomers(Guid customerID)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
return dao.GetCustomers(customerID);
}
}
}
public bool Update(CustomerBO customer)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
dao.Update(customer);
return true;
}
}
}
public bool Delete(Guid customerID)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
dao.Delete(customerID);
return true;
}
}
}
public bool Insert(CustomerBO customer)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (ICustomerDAO dao = factory.GetCustomerDAO(connection))
{
dao.Insert(customer);
return true;
}
}
}
}
}