public void Test_BuyNewComputer()
        {
            Computer c = new Computer("Bill Gates", "Microsoft-NB", "50GHz", "75GB", 88888);

            //skip check
            Assert.IsTrue(da.BuyNewComputer(c));
        }
        public bool BuyNewComputers(Computer[] cts)
        {
            bool bReturn = true;
            try
            {
                session = sessionFactory.OpenSession();
                tx = session.BeginTransaction();

                for(int i=0;i<cts.Length;i++)
                {
                    session.Save(cts[i]);
                }

                tx.Commit();
            }
            catch(Exception ex)
            {
                bReturn = false;
            }
            finally
            {
                session.Flush();
                session.Disconnect();
            }
            return bReturn;
        }
        public void Test_BuyNewComputers()
        {
            Computer[] cts = new Computer[2];
            cts[0] = new Computer("NewTon", "MacBook", "10GHz", "30GB", 16888);
            cts[1] = new Computer("DarWin", "PowerBook", "20GHz", "15GB", 36888);

            //skip check
            Assert.IsTrue(da.BuyNewComputers(cts));
        }
        public bool BuyNewComputer(Computer c)
        {
            bool bReturn = true;
            try
            {
                session = sessionFactory.OpenSession();
                tx = session.BeginTransaction();

                session.Save(c);

                tx.Commit();
            }
            catch(Exception ex)
            {
                bReturn = false;
            }
            finally
            {
                session.Flush();
                session.Disconnect();
            }
            return bReturn;
        }
 public Computer[] GetComputersByOwner(string Owner)
 {
     Computer[] computers = null;
     IList list = null;
     try
     {
         session = sessionFactory.OpenSession();
         qry = session.CreateQuery("from Computer where Owner='"+Owner+"'");
         list = qry.List();
         computers = new Computer[list.Count];
         list.CopyTo(computers, 0);
     }
     finally
     {
         session.Flush();
         session.Disconnect();
     }
     return computers;
 }