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