internal static List <Visit> GetVisitsWithinDates(DateTime start, DateTime end) { List <Visit> list = new List <Visit>();; using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { var res = session.CreateQuery(" FROM Visit WHERE VisitTime >= :start " + "AND VisitTime <= :end order by VisitTime") .SetParameter("start", start) .SetParameter("end", end) .List <Visit>(); list = (List <Visit>)res; //var res = session.CreateQuery("from Kid k where k.FirstName + ' ' + k.LastName = :name") // .SetParameter("name", kidName) } } return(list); }
private Boolean RegisterVisit(string kidName) { Visit v = new Visit(); Kid k = GetKid(kidName); v.KidId = k; using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { session.Save(v); transaction.Commit(); } catch (GenericADOException e) { Console.WriteLine(e.StackTrace); return(false); } } } return(true); }
public static object getAllKids() { List <object> list = new List <object>(); list.Add(""); using (ISession session = NHibernateHelper.OpenSession()) { if (session != null) { using (ITransaction transaction = session.BeginTransaction()) { var res = session.CreateCriteria(typeof(Kid)).List <Kid>(); foreach (var item in res) { if (item.Deleted == false) { list.Add(item.FirstName + " " + item.LastName); } } } } } return(list); }