2011-01-30 07:14:05 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2011-06-23 12:47:48 +00:00
|
|
|
|
using NHibernate;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
using Tanshu.Accounts.Entities.Auth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public class UserBI : FluentBase<User>
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public UserBI()
|
|
|
|
|
: base()
|
|
|
|
|
{ }
|
|
|
|
|
public UserBI(bool useTransaction)
|
|
|
|
|
: base(useTransaction)
|
|
|
|
|
{ }
|
|
|
|
|
public UserBI(ISession session)
|
|
|
|
|
: base(session)
|
|
|
|
|
{ }
|
|
|
|
|
public UserBI(ISession session, bool useTransaction)
|
|
|
|
|
: base(session, useTransaction)
|
|
|
|
|
{ }
|
2011-01-30 07:14:05 +00:00
|
|
|
|
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public IList<User> GetFilteredUsers(Dictionary<string, string> filter)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Session.QueryOver<User>()
|
|
|
|
|
.WhereRestrictionOn(x => x.Name).IsLike(string.Format("%{0}%", filter["Name"]))
|
|
|
|
|
.List();
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public bool ChangePassword(User userData, string newPassword)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
var dbUser = Get(x => x.Name == userData.Name && x.Password == userData.Password);
|
|
|
|
|
if (dbUser == null)
|
|
|
|
|
return false;
|
|
|
|
|
dbUser.Password = newPassword;
|
|
|
|
|
Session.Update(dbUser);
|
|
|
|
|
return true;
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public User ValidateUser(string name, string password)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Get(x => x.Name == name && x.Password == password);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public User MsrValidateUser(string msrString)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Get(x => x.MsrString == msrString);
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public IList<User> ListActive(DateTime startDate, DateTime finishDate)
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-03-11 18:49:48 +00:00
|
|
|
|
const string query = @"
|
|
|
|
|
select distinct(u) from Voucher v
|
|
|
|
|
inner join v.User u
|
|
|
|
|
where v.Date >= :startDate and v.Date <= :finishDate
|
|
|
|
|
order by u.Name";
|
2011-06-23 12:47:48 +00:00
|
|
|
|
return Session.CreateQuery(query)
|
2011-03-11 18:49:48 +00:00
|
|
|
|
.SetParameter("startDate", startDate)
|
|
|
|
|
.SetParameter("finishDate", finishDate)
|
|
|
|
|
.List<User>();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|