d8ecec8bb6
BillInventory Renamed. Refactored Bill to be more usable. Added Bill Detail Report. Added Open Bill and Bill Details Roles. Zero Rate Products have Yellow background Color. Refactored UserBI, FoodTableBI, ModifierBI, PrintLocationBI, ProductBI, ProductGroupBI, TaxBI, UserBI, Cached the Products List. Product and Product Group Form Working.
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NHibernate;
|
|
using Tanshu.Accounts.Entities.Auth;
|
|
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
public class UserBI : FluentBase<User>
|
|
{
|
|
public UserBI()
|
|
: base()
|
|
{ }
|
|
public UserBI(bool useTransaction)
|
|
: base(useTransaction)
|
|
{ }
|
|
public UserBI(ISession session)
|
|
: base(session)
|
|
{ }
|
|
public UserBI(ISession session, bool useTransaction)
|
|
: base(session, useTransaction)
|
|
{ }
|
|
|
|
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>();
|
|
}
|
|
}
|
|
}
|