69617949bd
Important! : This version will not work. It is pre-alpha and saved in case of catastrophic failure Refactor: Remove dependency on Fluent Nhibernate. Refactor: All Primary keys are now Guids. Refactor: Class Mappings changed from AutoMap to Explicit Mappings. Breakage: All Cascading is now disabled and entities must be explicitly saved/updated/deleted Breakage: Auto Commiting is now off and "SaveChanges()" needs to be called on all BIs. Refactor: Changed the pattern where all relevant db code for an operation is basically in the same function. Chore: Removed Advance and Payments options.
48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NHibernate;
|
|
using Tanshu.Accounts.Entities.Auth;
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
public class UserBI : UnitOfWork<User>
|
|
{
|
|
public IList<User> GetFilteredUsers(Dictionary<string, string> filter)
|
|
{
|
|
return _session.QueryOver<User>()
|
|
.WhereRestrictionOn(x => x.Name).IsLike(string.Format("%{0}%", filter["Name"]))
|
|
.List();
|
|
}
|
|
public bool ChangePassword(User userData, string newPassword)
|
|
{
|
|
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;
|
|
}
|
|
public User ValidateUser(string name, string password)
|
|
{
|
|
return Get(x => x.Name == name && x.Password == password);
|
|
}
|
|
public User MsrValidateUser(string msrString)
|
|
{
|
|
return Get(x => x.MsrString == msrString);
|
|
}
|
|
public IList<User> ListActive(DateTime startDate, DateTime finishDate)
|
|
{
|
|
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";
|
|
return _session.CreateQuery(query)
|
|
.SetParameter("startDate", startDate)
|
|
.SetParameter("finishDate", finishDate)
|
|
.List<User>();
|
|
}
|
|
}
|
|
}
|