2010-03-02 17:56:21 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Tanshu.Accounts.Contracts;
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.BI
|
|
|
|
|
{
|
2013-11-28 10:39:33 +00:00
|
|
|
|
public class UserBI
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
public UserBO GetUser(Guid userID)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.GetUser(userID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool ChangePassword(UserBO userData, string newPassword)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.ChangePassword(userData, newPassword);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public List<UserBO> GetUsers()
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.GetUsers();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public List<UserBO> GetFilteredUsers(Dictionary<string, string> filter)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.GetFilteredUsers(filter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool UserExists(string userName)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.UserExists(userName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool Insert(UserBO user)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.Insert(user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Update(UserBO user)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.Update(user);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Delete(Guid userID)
|
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
|
|
|
|
|
using (var connection = new SqlDAO.SqlConnectionDAO())
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
2013-11-16 06:01:58 +00:00
|
|
|
|
using (var dao = new SqlDAO.UserDAO(connection))
|
2010-03-02 17:56:21 +00:00
|
|
|
|
{
|
|
|
|
|
return dao.Delete(userID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|