Пример #1
0
        public void CustomerDaoTests()
        {
            Assert.AreEqual(91, customerDao.GetAll().Count);

            Customer c = new Customer(new DefaultCustomerClassificationCalculator());

            c.Id          = "MPOLL";
            c.CompanyName = "Interface21";
            customerDao.Save(c);
            c = customerDao.Get("MPOLL");
            Assert.AreEqual(c.Id, "MPOLL");
            Assert.AreEqual(c.CompanyName, "Interface21");

            //Without flushing, nothing changes in the database:
            int customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers");

            Assert.AreEqual(91, customerCount);

            //Flush the session to execute sql in the db.
            SessionFactoryUtils.GetSession(sessionFactory, true).Flush();

            //Now changes are visible outside the session but within the same database transaction
            customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers");
            Assert.AreEqual(92, customerCount);

            Assert.AreEqual(92, customerDao.GetAll().Count);

            c.CompanyName = "SpringSource";

            customerDao.Update(c);

            c = customerDao.Get("MPOLL");
            Assert.AreEqual(c.Id, "MPOLL");
            Assert.AreEqual(c.CompanyName, "SpringSource");

            customerDao.Delete(c);


            SessionFactoryUtils.GetSession(sessionFactory, true).Flush();
            customerCount = (int)AdoTemplate.ExecuteScalar(CommandType.Text, "select count(*) from Customers");
            Assert.AreEqual(92, customerCount);

            try
            {
                c = customerDao.Get("MPOLL");
                Assert.Fail("Should have thrown HibernateObjectRetrievalFailureException when finding customer with Id = MPOLL");
            }
            catch (HibernateObjectRetrievalFailureException e)
            {
                Assert.AreEqual("Customer", e.PersistentClassName);
            }
        }
Пример #2
0
 public void Update(CustomerDto customer)
 {
     customerDao.Update(DtoConverter.Convert(customer));
 }
Пример #3
0
 public void Update(Customer customer)
 {
     _customerDao.Update(customer);
 }
Пример #4
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     customerDao.Update(CurrentCustomer);
     SetResult("ViewCustomer");
 }
Пример #5
0
 public IResult Update(Customer customer)
 {
     _customerDao.Update(customer);
     return(new SuccessResult(Messages.UpdatedCustomer));
 }
 public void Update(long id, CustomerParam param)
 {
     Data.Entity.Customer oldEntity = CustomerDao.Find(id);
     Data.Entity.Customer newEntity = CustomerParamConverter.Convert(param, null);
     CustomerDao.Update(newEntity);
 }
 public void Update(Customer entity)
 {
     _customerDao.Update(entity);
 }