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

108 lines
3.3 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 UserBI : IUserBI
{
public UserBO GetUser(Guid userID)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.GetUser(userID);
}
}
}
public bool ChangePassword(UserBO userData, string newPassword)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.ChangePassword(userData, newPassword);
}
}
}
public List<UserBO> GetUsers()
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.GetUsers();
}
}
}
public List<UserBO> GetFilteredUsers(Dictionary<string, string> filter)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.GetFilteredUsers(filter);
}
}
}
public bool UserExists(string userName)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.UserExists(userName);
}
}
}
public bool Insert(UserBO user)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.Insert(user);
}
}
}
public bool Update(UserBO user)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.Update(user);
}
}
}
public bool Delete(Guid userID)
{
var factory = GetFactory.GetDAOFactory(Database.GetFactoryType);
using (var connection = factory.Connection)
{
using (IUserDAO dao = factory.GetUserDAO(connection))
{
return dao.Delete(userID);
}
}
}
}
}