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-29 20:27:07 +00:00
|
|
|
|
public class UserBI : FluentGenericBase<User>
|
2011-01-30 07:14:05 +00:00
|
|
|
|
{
|
2011-06-23 12:47:48 +00:00
|
|
|
|
public UserBI()
|
|
|
|
|
: base()
|
|
|
|
|
{ }
|
2011-06-29 20:27:07 +00:00
|
|
|
|
public UserBI(bool beginTransaction)
|
|
|
|
|
: base(beginTransaction)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{ }
|
|
|
|
|
public UserBI(ISession session)
|
|
|
|
|
: base(session)
|
|
|
|
|
{ }
|
2011-06-29 20:27:07 +00:00
|
|
|
|
public UserBI(ISession session, bool beginTransaction)
|
|
|
|
|
: base(session, beginTransaction)
|
2011-06-23 12:47:48 +00:00
|
|
|
|
{ }
|
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-29 20:27:07 +00:00
|
|
|
|
return Query()
|
2011-06-23 12:47:48 +00:00
|
|
|
|
.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-06-29 20:27:07 +00:00
|
|
|
|
const string query = @"
|
2011-03-11 18:49:48 +00:00
|
|
|
|
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-29 20:27:07 +00:00
|
|
|
|
return Session.CreateQuery(query)
|
|
|
|
|
.SetParameter("startDate", startDate)
|
|
|
|
|
.SetParameter("finishDate", finishDate)
|
|
|
|
|
.List<User>();
|
2011-03-11 18:49:48 +00:00
|
|
|
|
}
|
2011-06-29 20:27:07 +00:00
|
|
|
|
}
|
2011-01-30 07:14:05 +00:00
|
|
|
|
}
|