68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using Tanshu.Accounts.Contracts;
|
|
using System.Data.SqlClient;
|
|
using Tanshu.Data.DAO;
|
|
using Tanshu.Accounts.Entities;
|
|
using Tanshu.Accounts.SqlDAO;
|
|
using NHibernate.Criterion;
|
|
|
|
namespace Tanshu.Accounts.Repository
|
|
{
|
|
public static class WaiterBI
|
|
{
|
|
public static void Insert(Waiter waiter)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
session.Save(waiter);
|
|
}
|
|
}
|
|
public static void Update(Waiter waiter)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
session.Update(waiter);
|
|
}
|
|
}
|
|
public static bool Delete(int waiterID)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
session.Delete(new Waiter() { WaiterID = waiterID });
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public static Waiter GetWaiter(int waiterID)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
return session.Get<Waiter>(waiterID);
|
|
}
|
|
}
|
|
public static IList<Waiter> GetWaiters()
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
return session.CreateCriteria<Waiter>()
|
|
.List<Waiter>();
|
|
}
|
|
}
|
|
public static IList<Waiter> GetWaiters(string name)
|
|
{
|
|
using (var session = SessionManager.Session)
|
|
{
|
|
return session.CreateCriteria<Waiter>()
|
|
.Add(Restrictions.InsensitiveLike("Name", string.Format("%{0}%", name)))
|
|
.List<Waiter>();
|
|
}
|
|
}
|
|
public static IList<Waiter> GetFilteredWaiters(Dictionary<string, string> filter)
|
|
{
|
|
return GetWaiters(filter["Name"]);
|
|
}
|
|
}
|
|
}
|