public static IList <Product> listOfAllProduct() { IList <Product> products; ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); try { products = session.CreateCriteria <Product>().List <Product>(); } finally { session.Close(); } return(products); }
public static IList <User> listOfAllUser() { IList <User> users; ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); try { users = session.CreateCriteria <User>().List <User>(); } finally { session.Close(); } return(users); }
public static Sale createSale(Sale sale) { ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); try { session.SaveOrUpdate(sale); transaction.Commit(); } finally { session.Close(); } return(sale); }
public static User logIn(String username, String password) { User user; ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); user = (User)session.CreateQuery("From User u where u.Username = :username and u.Password = :password").SetParameter("username", username).SetParameter("password", password).UniqueResult(); if (user != null) { Console.WriteLine("Password Match " + user.Password); return(user); } user = null; return(user); }
public static Company updateCompany(Company model) { ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); try { session.Update(model); transaction.Commit(); } finally { session.Close(); } return(model); }
public static IList <Company> listOfAllCompany() { IList <Company> model; ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); try { model = session.CreateCriteria <Company>().List <Company>(); } finally { session.Close(); } return(model); }
public static Product deleteProduct(Product product) { ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); try { session.Delete(product); transaction.Commit(); } finally { session.Close(); } return(product); }
public static User deleteUser(User user) { ISession session = HibernateHelper.GetSessionFactory().OpenSession(); ITransaction transaction = session.BeginTransaction(); try { session.Delete(user); transaction.Commit(); } finally { session.Close(); } return(user); }