コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }